ci cd #191
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: Rust | |
| on: | |
| push: | |
| branches: ["main"] | |
| tags: ["v*.*.*"] | |
| pull_request: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| workflow_call: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| tip_release_path: RELEASE.md | |
| jobs: | |
| test-build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: "macos-latest", target: "aarch64-apple-darwin" } | |
| - { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu" } | |
| - { | |
| os: "windows-latest", | |
| target: "x86_64-pc-windows-msvc", | |
| ext: ".exe", | |
| } | |
| - { os: "ubuntu-24.04-arm", target: "aarch64-unknown-linux-gnu" } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup sccache | |
| if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
| uses: mozilla-actions/sccache-action@v0.0.8 | |
| - name: Configure sccache | |
| if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
| run: | | |
| echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV" | |
| echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" | |
| - name: Setup rust cache action | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: true | |
| - name: install build dependencies on ubuntu and cache | |
| if: contains(matrix.os, 'ubuntu') | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: libfontconfig1-dev libgoogle-perftools-dev google-perftools | |
| version: latest # could be anything | |
| - name: Install clippy and fmt | |
| run: rustup component add clippy rustfmt | |
| - name: Clippy | |
| run: cargo clippy --locked -- -D warnings | |
| - name: Tests | |
| run: cargo test --locked | |
| - name: Check fmt | |
| run: cargo fmt -- --check | |
| - name: Run benchmarks as tests | |
| run: cargo test --locked --benches -- adobe_example | |
| - name: Set build mode | |
| shell: bash | |
| run: if [ "${{github.ref_type}}" == "tag" ] || [ ${{ github.event_name == 'push' && github.ref_name == 'main' }} ]; then echo "BMODE=production">>"$GITHUB_ENV"; fi | |
| - name: Build in ${{env.BMODE || 'debug'}} mode | |
| run: cargo build --verbose --locked --profile ${{env.BMODE || 'dev'}} | |
| - name: Prepare artifact | |
| shell: bash | |
| run: | | |
| mkdir -p dist | |
| cp "target/${{env.BMODE || 'debug'}}/tdf${{ matrix.ext }}" dist/tdf-${{ matrix.target }}${{ matrix.ext }} | |
| tree dist || ls -la dist | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: tdf-${{ matrix.target }} | |
| path: dist/tdf* | |
| tag-release: | |
| name: Release on tag push | |
| runs-on: ubuntu-slim | |
| if: github.ref_type == 'tag' | |
| needs: test-build | |
| steps: | |
| - uses: actions/download-artifact@v6 | |
| with: | |
| pattern: "**/tdf-*" | |
| path: release-artifacts | |
| merge-multiple: true | |
| - name: What's up? | |
| run: tree release-artifacts # beautiful! | |
| - name: Create a GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| draft: true | |
| generate_release_notes: true | |
| files: release-artifacts/* | |
| prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} | |
| tip-release: | |
| name: Release tip on push to main | |
| runs-on: ubuntu-slim | |
| if: github.event_name == 'push' && github.ref_name == 'main' | |
| needs: test-build | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download prebuilt artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: release-artifacts | |
| merge-multiple: true | |
| - name: Generate release notes | |
| run: | | |
| tree release-artifacts/ | |
| echo "From commit: $(git rev-parse --short HEAD)" > ${{ env.tip_release_path }} | |
| echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> ${{ env.tip_release_path }} | |
| cat ${{ env.tip_release_path }} | |
| - name: Update the tip tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag --force tip && git push --force origin tag tip | |
| - name: Update the draft tip release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| prerelease: true | |
| files: release-artifacts/* | |
| tag_name: tip | |
| name: Tip Build | |
| body_path: ${{ env.tip_release_path }} |