diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ee930b..3a2f45a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,13 +6,41 @@ on: pull_request: branches: [master] +permissions: + contents: read + +# A newer push to the same pull request makes the older run moot. +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 + with: + persist-credentials: false - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt - uses: Swatinem/rust-cache@v2 - run: cargo fmt --all --check - run: cargo clippy --workspace --all-targets -- -D warnings - run: cargo test --workspace + + # Releases ship macOS and Windows binaries; build them on every change, not first at tag time. + build: + name: build (${{ matrix.os }}) + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo build --workspace diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b947ceb..cbcb199 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,9 @@ jobs: artifact: scriptmark.exe steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 + with: + persist-credentials: false - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} @@ -52,7 +54,7 @@ jobs: run: cargo build --release -p scriptmark --target ${{ matrix.target }} - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: scriptmark-${{ matrix.target }} path: target/${{ matrix.target }}/release/${{ matrix.artifact }} @@ -67,7 +69,7 @@ jobs: steps: - name: Download binaries - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: path: artifacts pattern: scriptmark-* @@ -83,7 +85,7 @@ jobs: chmod +x release/scriptmark-* - name: Create GitHub Release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@v3 with: generate_release_notes: true files: release/* @@ -99,8 +101,19 @@ jobs: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 + with: + persist-credentials: false - uses: dtolnay/rust-toolchain@stable - - name: Publish crate + # Trusted Publishing: exchange this job's OIDC token for a short-lived crates.io token. + # Each crate must be configured on crates.io (Settings → Trusted Publishing: repository + # Acture/scriptmark, workflow release.yml, environment release), and a crate's first + # version must be published by hand with an API token. + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + + - name: Publish crates run: cargo publish --workspace + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}