-
Notifications
You must be signed in to change notification settings - Fork 66
ci cd #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci cd #132
Changes from 6 commits
873fd2c
32d5e02
1ae3ee5
62f24f6
c9c5b4d
c515a4f
44e4d5d
3893f62
42baf43
bc54b89
d58c0c7
f996c0f
7374619
30c6f88
1c3907f
a90b28d
2dc387e
8f0d16b
49df524
5c4a14c
da43ba6
192fa92
572ceeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,41 +2,144 @@ name: Rust | |
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| branches: ["main"] | ||
| tags: ["v*.*.*"] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
| workflow_call: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| tip_release_path: RELEASE.md | ||
|
|
||
| jobs: | ||
| build: | ||
| 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: ubuntu-latest | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| steps: | ||
| - 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: Install build dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libfontconfig1-dev libgoogle-perftools-dev google-perftools | ||
| - uses: actions/checkout@v4 | ||
| - 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: Build | ||
| run: cargo build --locked | ||
| - 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=release">>"$GITHUB_ENV"; fi | ||
|
|
||
| - name: Build in ${{env.BMODE || 'debug'}} mode | ||
| run: cargo build --verbose --locked --${{env.BMODE}} | ||
|
jarjk marked this conversation as resolved.
Outdated
|
||
|
|
||
| - 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 | ||
|
jarjk marked this conversation as resolved.
Outdated
|
||
| generate_release_notes: true | ||
| files: release-artifacts/* | ||
| prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} | ||
|
|
||
| tip-release: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand the usefulness or purpose of this workflow - does it just overwrite the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, there's a release, that's always updated on commits to eg: |
||
| 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 }} | ||
Uh oh!
There was an error while loading. Please reload this page.