Skip to content

Github workflow update #126

Github workflow update

Github workflow update #126

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'New tag name'
required: true
push:
tags:
- '*'
pull_request:
env:
TMP_LOCAL_IMAGE: localhost:5000/exein-io/pulsar
REGISTRY_IMAGE: ghcr.io/exein-io/pulsar
REGISTRY_TAG: dev
jobs:
vendored_archive:
name: Vendored archive
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Create release directory
run: rsync -rv --exclude=.git . ../pulsar-${{ github.event.ref }}
- name: Cargo vendor
working-directory: ../pulsar-${{ github.event.ref }}
run: |
mkdir ../vendor-cargo-home
export CARGO_HOME=$(realpath ../vendor-cargo-home)
mkdir -p .cargo
cargo vendor >> .cargo/config.toml
- name: Create vendored source archive
working-directory: ../
run: tar cJf pulsar-${{ github.event.ref }}.tar.xz pulsar-${{ github.event.ref }}
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
draft: true
files: ../pulsar-${{ github.event.ref }}.tar.xz
body: |
<hr>
Check out the [changelog](https://github.com/Exein-io/pulsar/blob/main/CHANGELOG.md) for details on all the changes and fixes.
build:
name: Create binary
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- target: x86_64-unknown-linux-gnu
args: "--features full"
docker-base-image: debian:bookworm
docker-platform: linux/amd64
- target: aarch64-unknown-linux-gnu
args: "--features full"
docker-base-image: debian:bookworm
docker-platform: linux/arm64
- target: riscv64gc-unknown-linux-gnu
args: "--features full"
docker-base-image: debian:sid
docker-platform: linux/riscv64
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Install Rust toolchain (stable)
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.platform.target }}
- name: Install cross
uses: ./.github/actions/install-cross
- name: Build Release
run: cross build --locked --target=${{ matrix.platform.target }} --bin pulsar-exec ${{ matrix.platform.args }} --release
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ matrix.platform.docker-platform != null }}
- name: Prepare Docker image directory
if: ${{ matrix.platform.docker-platform != null }}
run: |
mkdir -p /tmp/images
platform=${{ matrix.platform.target }}
echo "TARFILE=${platform//\//-}.tar" >> $GITHUB_ENV
echo "TAG=${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-}" >> $GITHUB_ENV
- name: Create Docker image
uses: docker/build-push-action@v5
if: ${{ matrix.platform.docker-platform != null }}
with:
context: "."
file: .github/docker/Dockerfile
build-args: |
BASE_IMAGE=${{ matrix.platform.docker-base-image }}
ARCH=${{ matrix.platform.target }}
platforms: ${{ matrix.platform.docker-platform }}
tags: ${{ env.TAG }}
outputs: type=docker,dest=/tmp/images/${{ env.TARFILE }}
- name: Upload Docker image
uses: actions/upload-artifact@v3
if: ${{ matrix.platform.docker-platform != null }}
with:
name: images
path: /tmp/images/${{ env.TARFILE }}
if-no-files-found: error
retention-days: 1
- name: Rename binary
shell: bash
id: rename_binary
run: |
IFS='-' read -a arch <<< ${{ matrix.platform.target }}
suffix=""
if [[ "${{ matrix.platform.target }}" == *"musl"* ]]; then suffix="-static"; fi
binary_name=./target/${{ matrix.platform.target }}/release/pulsar-exec-${arch}${suffix}
mv ./target/${{ matrix.platform.target }}/release/pulsar-exec ${binary_name}
echo "binary_name=${binary_name}" >> $GITHUB_OUTPUT
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
draft: true
files: ${{ steps.rename_binary.outputs.binary_name }}
body: |
<hr>
Check out the [changelog](https://github.com/Exein-io/pulsar/blob/main/CHANGELOG.md) for details on all the changes and fixes.
docker-push:
name: Push docker multi-arch image
runs-on: ubuntu-latest
needs:
- build
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Download images
uses: actions/download-artifact@v3
with:
name: images
path: /tmp/images
- name: Load images
run: |
for image in /tmp/images/*.tar; do
docker load -i $image
done
- name: Push images to local registry
run: |
docker push -a ${{ env.TMP_LOCAL_IMAGE }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }} \
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ')
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}