Skip to content

version: Version Bump 🚀 0.4.3-alpha.1 #161

version: Version Bump 🚀 0.4.3-alpha.1

version: Version Bump 🚀 0.4.3-alpha.1 #161

Workflow file for this run

name: release
on:
pull_request:
types: [closed]
branches: [main]
workflow_dispatch:
inputs:
dry_run:
description: Dry run
required: true
default: true
type: boolean
permissions:
contents: write
packages: write
id-token: write
jobs:
compute-dry-run:
runs-on: ubuntu-latest
# only run if workflow dispatch or pull request merged *with* tag 'version-bump'
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'version-bump')
)
outputs:
is_dry_run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true' }}
steps:
- name: Compute effective dry-run
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] \
&& [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "Running in DRY-RUN mode"
else
echo "Running in LIVE mode"
fi
create-tag:
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
needs: ["compute-dry-run"]
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Get current version
id: version
uses: mozilla-ai/cargo-goose/actions/current-version@v1
with:
force-single-version: true
- name: Create git tag
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
run: |
VERSION=${{ steps.version.outputs.version }}
git tag -a "v$VERSION" -m "Version $VERSION" || true
git push origin "v$VERSION" || true
- name: Dry-run tag
if: needs.compute-dry-run.outputs.is_dry_run == 'true'
run: echo "[DRY RUN] would create tag v${{ steps.version.outputs.version }}"
build-macos:
needs: [create-tag, compute-dry-run]
runs-on: macos-14
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/project-setup
- run: rustup target add ${{ matrix.target }}
- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
mkdir -p dist
cp target/${{ matrix.target }}/release/encoderfile dist/
cp target/${{ matrix.target }}/release/encoderfile-runtime dist/
- name: Package
run: |
mkdir pkg
cp dist/* README.md LICENSE pkg/
test -f THIRDPARTY.md && cp THIRDPARTY.md pkg/
tar -czf encoderfile-${{ matrix.target }}.tar.gz -C pkg .
tar -czf encoderfile-runtime-${{ matrix.target }}.tar.gz -C pkg .
- uses: actions/upload-artifact@v4
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
with:
name: macos-${{ matrix.target }}
path: "*.tar.gz"
build-linux:
needs: [create-tag, compute-dry-run]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- name: Build (bookworm, ${{ matrix.arch }})
run: |
docker build \
-f Dockerfile \
--target build \
--load \
-t encoderfile-build:${{ matrix.arch }} \
.
CID=$(docker create encoderfile-build:${{ matrix.arch }})
mkdir -p dist
docker cp "$CID:/app/target/release/encoderfile" dist/
docker cp "$CID:/app/target/release/encoderfile-runtime" dist/
docker rm "$CID"
- name: Package
run: |
mkdir pkg
cp dist/* README.md LICENSE pkg/
test -f THIRDPARTY.md && cp THIRDPARTY.md pkg/
tar -czf encoderfile-${{ matrix.target }}.tar.gz -C pkg .
tar -czf encoderfile-runtime-${{ matrix.target }}.tar.gz -C pkg .
- uses: actions/upload-artifact@v4
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
with:
name: linux-${{ matrix.arch }}
path: "*.tar.gz"
release:
needs: [create-tag, build-macos, build-linux, compute-dry-run]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
- uses: softprops/action-gh-release@v2
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
with:
tag_name: v${{ needs.create-tag.outputs.version }}
name: v${{ needs.create-tag.outputs.version }}
prerelease: ${{ needs.create-tag.outputs.prerelease }}
files: dist/**/*.tar.gz
generate_release_notes: true
docker-build:
needs: [release, create-tag, compute-dry-run]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-latest
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build image
run: |
docker build \
--platform ${{ matrix.platform }} \
-t ghcr.io/${{ github.repository_owner }}/encoderfile:${{ matrix.arch }}-${{ needs.create-tag.outputs.version }} \
.
- name: Push image
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
run: |
docker push \
ghcr.io/${{ github.repository_owner }}/encoderfile:${{ matrix.arch }}-${{ needs.create-tag.outputs.version }}
docker-manifest:
needs: [docker-build, create-tag, compute-dry-run]
runs-on: ubuntu-latest
steps:
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Bundle dockerfiles
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
run: |
VERSION=${{ needs.create-tag.outputs.version }}
PRE=${{ needs.create-tag.outputs.prerelease }}
if [[ "$PRE" == "true" ]]; then
docker buildx imagetools create \
-t ghcr.io/${{ github.repository_owner }}/encoderfile:${VERSION} \
ghcr.io/${{ github.repository_owner }}/encoderfile:amd64-${VERSION} \
ghcr.io/${{ github.repository_owner }}/encoderfile:arm64-${VERSION}
else
docker buildx imagetools create \
-t ghcr.io/${{ github.repository_owner }}/encoderfile:${VERSION} \
-t ghcr.io/${{ github.repository_owner }}/encoderfile:latest \
ghcr.io/${{ github.repository_owner }}/encoderfile:amd64-${VERSION} \
ghcr.io/${{ github.repository_owner }}/encoderfile:arm64-${VERSION}
fi
publish-encoderfile:
needs: [release, compute-dry-run]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/project-setup
- name: Cargo publish (dry-run)
run: cargo publish -p encoderfile --dry-run
- name: Cargo publish
if: needs.compute-dry-run.outputs.is_dry_run != 'true'
run: cargo publish -p encoderfile
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}