fix(ci): remove --allow-dirty from cargo publish #52
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: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: "Re-release the current tag (use when a previous release partially failed)" | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| ci: | |
| uses: ./.github/workflows/ci.yml | |
| release: | |
| needs: ci | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| released: ${{ steps.sr.outputs.released }} | |
| tag: ${{ steps.sr.outputs.tag }} | |
| steps: | |
| - name: Generate app token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ secrets.SR_RELEASER_APP_ID }} | |
| private-key: ${{ secrets.SR_RELEASER_PRIVATE_KEY }} | |
| repositories: ${{ github.event.repository.name }} | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Run semantic release | |
| id: sr | |
| uses: urmzd/sr@v3 | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| force: ${{ inputs.force }} | |
| publish: | |
| needs: release | |
| if: needs.release.outputs.released == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| environment: crates-io | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Get crates.io publish token | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| id: crates-token | |
| - name: Publish lgp to crates.io | |
| run: | | |
| output=$(cargo publish -p lgp 2>&1) && exit 0 | |
| if echo "$output" | grep -q "already exists"; then | |
| echo "Already published, skipping" | |
| exit 0 | |
| fi | |
| echo "$output" >&2 | |
| exit 1 | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.crates-token.outputs.token }} | |
| binaries: | |
| needs: release | |
| if: needs.release.outputs.released == 'true' | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ 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 | |
| echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml | |
| echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml | |
| - name: Build binary | |
| run: cargo build --release --target ${{ matrix.target }} -p lgp | |
| - name: Package binary | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar -czf lgp-${{ matrix.target }}.tar.gz lgp | |
| mv lgp-${{ matrix.target }}.tar.gz "$GITHUB_WORKSPACE/" | |
| - name: Upload release asset | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload ${{ needs.release.outputs.tag }} lgp-${{ matrix.target }}.tar.gz --clobber | |
| experiments: | |
| needs: release | |
| if: needs.release.outputs.released == 'true' | |
| uses: ./.github/workflows/experiments.yml | |
| with: | |
| experiment_type: experiments | |
| iterations: "10" |