v0.2.0 #2
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| release: | |
| types: [created] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v0.1.0)" | |
| required: true | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| IMAGE_NAME: budstudio/taskgraph | |
| jobs: | |
| resolve-tag: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.tag.outputs.tag }} | |
| steps: | |
| - name: Resolve release tag | |
| id: tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" | |
| elif [ "${{ github.event_name }}" = "release" ]; then | |
| echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| needs: resolve-tag | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| asset: taskgraph-linux-x86_64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| asset: taskgraph-linux-aarch64 | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| asset: taskgraph-darwin-x86_64 | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| asset: taskgraph-darwin-aarch64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.resolve-tag.outputs.tag }} | |
| - name: Install Rust toolchain | |
| run: | | |
| rustup target add ${{ matrix.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Build | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package binary | |
| run: | | |
| cp target/${{ matrix.target }}/release/taskgraph ${{ matrix.asset }} | |
| chmod +x ${{ matrix.asset }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.asset }} | |
| path: ${{ matrix.asset }} | |
| release: | |
| needs: [resolve-tag, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.resolve-tag.outputs.tag }} | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir release | |
| for dir in artifacts/*/; do | |
| cp "$dir"* release/ | |
| done | |
| cd release | |
| sha256sum taskgraph-* > checksums.txt | |
| cat checksums.txt | |
| - name: Create or update GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.resolve-tag.outputs.tag }} | |
| generate_release_notes: true | |
| files: release/* | |
| docker: | |
| needs: [resolve-tag, release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.resolve-tag.outputs.tag }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,value=${{ needs.resolve-tag.outputs.tag }},pattern={{version}} | |
| type=semver,value=${{ needs.resolve-tag.outputs.tag }},pattern={{major}}.{{minor}} | |
| type=raw,value=latest | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| 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 |