Initial commit #15
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Development Release | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| tags-ignore: | |
| - "**" | |
| env: | |
| BIN_NAME: ${{ github.event.repository.name }} | |
| REGISTRY: ghcr.io | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-dev: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| cpu: x86-64-v3 | |
| install_deps: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| cpu: x86-64-v3 | |
| install_deps: "false" | |
| - target: aarch64-unknown-linux-musl | |
| os: ubuntu-24.04-arm | |
| cpu: neoverse-n1 | |
| install_deps: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-24.04-arm | |
| cpu: neoverse-n1 | |
| install_deps: "false" | |
| - target: x86_64-apple-darwin | |
| os: macos-15-intel | |
| cpu: x86-64-v3 | |
| install_deps: "false" | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| cpu: apple-m1 | |
| install_deps: "false" | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| cpu: x86-64-v3 | |
| install_deps: "false" | |
| - target: aarch64-pc-windows-msvc | |
| os: windows-11-arm | |
| cpu: cortex-a76 | |
| install_deps: "false" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install System Dependencies | |
| if: matrix.install_deps != 'false' | |
| run: ${{ matrix.install_deps }} | |
| - name: Install Rust Toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: stable | |
| targets: ${{ matrix.target }} | |
| - name: Rust Cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Set Development Version | |
| shell: bash | |
| run: | | |
| BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2) | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}" | |
| sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml | |
| # RUSTFLAGS="-C target_cpu=native" and apple-m1 CPUs cause brittle behavior | |
| - name: Delete Cargo Config | |
| shell: bash | |
| run: rm -f .cargo/config.toml | |
| - name: Build Binary | |
| env: | |
| RUSTFLAGS: "-C target-cpu=${{ matrix.cpu }}" | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package Binary | |
| shell: bash | |
| run: | | |
| mkdir dist | |
| cp LICENSE README.md dist/ | |
| if [[ "${{ matrix.target }}" == *"windows"* ]]; then | |
| cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" dist/ | |
| cd dist | |
| 7z a "../${{ env.BIN_NAME }}-${{ matrix.target }}.zip" "${{ env.BIN_NAME }}.exe" LICENSE README.md | |
| else | |
| cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" dist/ | |
| cd dist | |
| tar -czf "../${{ env.BIN_NAME }}-${{ matrix.target }}.tar.gz" "${{ env.BIN_NAME }}" LICENSE README.md | |
| fi | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: binary-${{ matrix.target }} | |
| path: ${{ env.BIN_NAME }}-${{ matrix.target }}* | |
| retention-days: 1 | |
| release-dev: | |
| name: Update Development Release | |
| needs: build-dev | |
| continue-on-error: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Update Pre-Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: dev | |
| name: Development Release | |
| body: "Latest development build from master.\n\nCommit: ${{ github.sha }}." | |
| files: artifacts/* | |
| prerelease: true | |
| make_latest: false | |
| docker-dev: | |
| name: Push Development Docker | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set Development Version | |
| shell: bash | |
| run: | | |
| BASE_VERSION=$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f 2) | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| NEW_VERSION="${BASE_VERSION}-dev.${SHORT_SHA}" | |
| sed -i.bak "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ github.repository }} | |
| tags: | | |
| type=raw,value=dev | |
| type=sha,prefix=dev-,format=short | |
| type=sha,prefix=dev-,format=long | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| build-args: LOCK_FLAG= | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |