From f82029071e11ee435def08ce2e6b4acc1c83bff4 Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Sat, 28 Jun 2025 16:42:34 -0700 Subject: [PATCH 1/2] ci: remove deprecated actions and use stable nightly is only necessary for formatting. For most things in git-cliff stable is sufficient. So use stable for everything else. actions-rs/toolchain was archived years ago. Generally use dtolnay/rust-toolchain as a replacement actions-rs/cargo is similarly archived. Use plain cargo commands taike-e/install-action automatically uses cargo-binstall to install tools not setup for install-action directly. So there's no need to install binstall to install cargo-msrv --- .github/actions/run-fixtures-test/action.yml | 2 +- .github/workflows/cd.yml | 18 +------- .github/workflows/ci.yml | 44 ++++++-------------- rust-toolchain.toml | 2 +- 4 files changed, 16 insertions(+), 50 deletions(-) diff --git a/.github/actions/run-fixtures-test/action.yml b/.github/actions/run-fixtures-test/action.yml index ba6c52e7c1..32e19a24d2 100644 --- a/.github/actions/run-fixtures-test/action.yml +++ b/.github/actions/run-fixtures-test/action.yml @@ -22,7 +22,7 @@ runs: using: composite steps: - name: Install toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@stable - name: Install git-cliff run: cargo install --path git-cliff/ --profile dev diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b5379035ae..f0ddd02f3d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -34,7 +34,6 @@ jobs: - { NAME: linux-x64-glibc, OS: ubuntu-22.04, - TOOLCHAIN: stable, TARGET: x86_64-unknown-linux-gnu, NPM_PUBLISH: true, PYPI_PUBLISH: true, @@ -42,7 +41,6 @@ jobs: - { NAME: linux-x64-musl, OS: ubuntu-22.04, - TOOLCHAIN: stable, TARGET: x86_64-unknown-linux-musl, NPM_PUBLISH: false, PYPI_PUBLISH: true, @@ -50,7 +48,6 @@ jobs: - { NAME: linux-x86-glibc, OS: ubuntu-22.04, - TOOLCHAIN: stable, TARGET: i686-unknown-linux-gnu, NPM_PUBLISH: false, PYPI_PUBLISH: false, @@ -58,7 +55,6 @@ jobs: - { NAME: linux-x86-musl, OS: ubuntu-22.04, - TOOLCHAIN: stable, TARGET: i686-unknown-linux-musl, NPM_PUBLISH: false, PYPI_PUBLISH: true, @@ -66,7 +62,6 @@ jobs: - { NAME: linux-arm64-glibc, OS: ubuntu-22.04, - TOOLCHAIN: stable, TARGET: aarch64-unknown-linux-gnu, NPM_PUBLISH: true, PYPI_PUBLISH: true, @@ -74,7 +69,6 @@ jobs: - { NAME: linux-arm64-musl, OS: ubuntu-22.04, - TOOLCHAIN: stable, TARGET: aarch64-unknown-linux-musl, NPM_PUBLISH: false, PYPI_PUBLISH: true, @@ -82,7 +76,6 @@ jobs: - { NAME: win32-x64-mingw, OS: windows-2022, - TOOLCHAIN: stable, TARGET: x86_64-pc-windows-gnu, NPM_PUBLISH: false, PYPI_PUBLISH: false, @@ -90,7 +83,6 @@ jobs: - { NAME: win32-x64-msvc, OS: windows-2022, - TOOLCHAIN: stable, TARGET: x86_64-pc-windows-msvc, NPM_PUBLISH: true, PYPI_PUBLISH: true, @@ -98,7 +90,6 @@ jobs: - { NAME: win32-x86-msvc, OS: windows-2022, - TOOLCHAIN: stable, TARGET: i686-pc-windows-msvc, NPM_PUBLISH: false, PYPI_PUBLISH: true, @@ -106,7 +97,6 @@ jobs: - { NAME: win32-arm64-msvc, OS: windows-2022, - TOOLCHAIN: stable, TARGET: aarch64-pc-windows-msvc, NPM_PUBLISH: true, PYPI_PUBLISH: false, @@ -114,7 +104,6 @@ jobs: - { NAME: darwin-x64, OS: macos-14, - TOOLCHAIN: stable, TARGET: x86_64-apple-darwin, NPM_PUBLISH: true, PYPI_PUBLISH: true, @@ -122,7 +111,6 @@ jobs: - { NAME: darwin-arm64, OS: macos-14, - TOOLCHAIN: stable, TARGET: aarch64-apple-darwin, NPM_PUBLISH: true, PYPI_PUBLISH: true, @@ -142,11 +130,9 @@ jobs: --allow-unauthenticated musl-tools fi - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: ${{ matrix.build.TOOLCHAIN }} - target: ${{ matrix.build.TARGET }} - override: true + targets: ${{ matrix.build.TARGET }} - name: Build (linux/macos) if: matrix.build.OS != 'windows-2022' uses: actions-rs/cargo@v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4f8bee898..bdc0b62141 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,15 +23,9 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Check - uses: actions-rs/cargo@v1 - with: - command: check - args: --locked --verbose + run: cargo check --locked --verbose - name: Check without default features - uses: actions-rs/cargo@v1 - with: - command: check - args: --locked --no-default-features --verbose + run: cargo check --locked --no-default-features --verbose typos: name: Typos @@ -84,21 +78,15 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install toolchain - uses: dtolnay/rust-toolchain@nightly + uses: dtolnay/rust-toolchain@stable with: components: clippy - name: Checkout uses: actions/checkout@v4 - name: Check the lints - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --tests --verbose -- -D warnings + run: cargo clippy --tests --verbose -- -D warnings - name: Check the pedantic lints - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-targets --verbose -- -W clippy::pedantic + run: cargo clippy --all-targets --verbose -- -W clippy::pedantic rustfmt: name: Formatting @@ -111,26 +99,18 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Check the formatting - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check --verbose + run: cargo fmt --all -- --check --verbose doctest: name: Doctests runs-on: ubuntu-22.04 steps: - name: Install toolchain - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt + uses: dtolnay/rust-toolchain@stable - name: Checkout uses: actions/checkout@v4 - - name: Check the formatting - uses: actions-rs/cargo@v1 - with: - command: test - args: --doc + - name: Check the doc tests + run: cargo test --doc lychee: name: Links @@ -151,10 +131,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Install cargo-binstall - uses: taiki-e/install-action@cargo-binstall - name: Install cargo-msrv - run: cargo binstall -y cargo-msrv + uses: taiki-e/install-action@v2 + with: + tool: cargo-msrv - name: Run cargo-msrv shell: bash run: | diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d56faf9ae..292fe499e3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" +channel = "stable" From 2bdb76eb29f5d182e543a6f8bbbc09c76dfcb48d Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Mon, 30 Jun 2025 18:08:40 -0700 Subject: [PATCH 2/2] ci: simplify cd.yml - Use matrix include instead of an object per build - simplify some conditional logic - use latest os versions - use arm versions instead of cross compiling --- .github/workflows/cd.yml | 236 +++++++++++++++++---------------------- 1 file changed, 100 insertions(+), 136 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f0ddd02f3d..893e66b562 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -26,126 +26,93 @@ jobs: publish-binaries: name: Publish binaries needs: generate-changelog - runs-on: ${{ matrix.build.os }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - build: - - { - NAME: linux-x64-glibc, - OS: ubuntu-22.04, - TARGET: x86_64-unknown-linux-gnu, - NPM_PUBLISH: true, - PYPI_PUBLISH: true, - } - - { - NAME: linux-x64-musl, - OS: ubuntu-22.04, - TARGET: x86_64-unknown-linux-musl, - NPM_PUBLISH: false, - PYPI_PUBLISH: true, - } - - { - NAME: linux-x86-glibc, - OS: ubuntu-22.04, - TARGET: i686-unknown-linux-gnu, - NPM_PUBLISH: false, - PYPI_PUBLISH: false, - } - - { - NAME: linux-x86-musl, - OS: ubuntu-22.04, - TARGET: i686-unknown-linux-musl, - NPM_PUBLISH: false, - PYPI_PUBLISH: true, - } - - { - NAME: linux-arm64-glibc, - OS: ubuntu-22.04, - TARGET: aarch64-unknown-linux-gnu, - NPM_PUBLISH: true, - PYPI_PUBLISH: true, - } - - { - NAME: linux-arm64-musl, - OS: ubuntu-22.04, - TARGET: aarch64-unknown-linux-musl, - NPM_PUBLISH: false, - PYPI_PUBLISH: true, - } - - { - NAME: win32-x64-mingw, - OS: windows-2022, - TARGET: x86_64-pc-windows-gnu, - NPM_PUBLISH: false, - PYPI_PUBLISH: false, - } - - { - NAME: win32-x64-msvc, - OS: windows-2022, - TARGET: x86_64-pc-windows-msvc, - NPM_PUBLISH: true, - PYPI_PUBLISH: true, - } - - { - NAME: win32-x86-msvc, - OS: windows-2022, - TARGET: i686-pc-windows-msvc, - NPM_PUBLISH: false, - PYPI_PUBLISH: true, - } - - { - NAME: win32-arm64-msvc, - OS: windows-2022, - TARGET: aarch64-pc-windows-msvc, - NPM_PUBLISH: true, - PYPI_PUBLISH: false, - } - - { - NAME: darwin-x64, - OS: macos-14, - TARGET: x86_64-apple-darwin, - NPM_PUBLISH: true, - PYPI_PUBLISH: true, - } - - { - NAME: darwin-arm64, - OS: macos-14, - TARGET: aarch64-apple-darwin, - NPM_PUBLISH: true, - PYPI_PUBLISH: true, - } + include: + - name: linux-x64-glibc + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + publish_npm: true + publish_pypi: true + - name: linux-x64-musl + os: ubuntu-latest + target: x86_64-unknown-linux-musl + publish_npm: false + publish_pypi: true + install_musl: true + - name: linux-x86-glibc + os: ubuntu-latest + target: i686-unknown-linux-gnu + publish_npm: false + publish_pypi: false + - name: linux-x86-musl + os: ubuntu-latest + target: i686-unknown-linux-musl + publish_npm: false + publish_pypi: true + install_musl: true + - name: linux-arm64-glibc + os: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + publish_npm: true + publish_pypi: true + - name: linux-arm64-musl + os: ubuntu-24.04-arm + target: aarch64-unknown-linux-musl + publish_npm: false + publish_pypi: true + install_musl: true + - name: win32-x64-mingw + os: windows-latest + target: x86_64-pc-windows-gnu + publish_npm: false + publish_pypi: false + - name: win32-x64-msvc + os: windows-latest + target: x86_64-pc-windows-msvc + publish_npm: true + publish_pypi: true + - name: win32-x86-msvc + os: windows-latest + target: i686-pc-windows-msvc + publish_npm: false + publish_pypi: true + - name: win32-arm64-msvc + os: windows-11-arm + target: aarch64-pc-windows-msvc + publish_npm: true + publish_pypi: false + - name: darwin-x64 + os: macos-13 + target: x86_64-apple-darwin + publish_npm: true + publish_pypi: true + - name: darwin-arm64 + os: macos-latest + target: aarch64-apple-darwin + publish_npm: true + publish_pypi: true steps: - name: Checkout uses: actions/checkout@v4 - name: Set the release version shell: bash run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV - - name: Install dependencies + - name: Install Musl tools + if: matrix.install_musl shell: bash run: | - if [[ "${{ matrix.build.NAME }}" = *"-musl" ]]; then - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - --allow-unauthenticated musl-tools - fi + sudo apt-get update + sudo apt-get install -y --no-install-recommends --allow-unauthenticated \ + musl-tools - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: - targets: ${{ matrix.build.TARGET }} - - name: Build (linux/macos) - if: matrix.build.OS != 'windows-2022' - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --release --locked --target ${{ matrix.build.TARGET }} - - name: Build (windows) - if: matrix.build.OS == 'windows-2022' - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --locked --target ${{ matrix.build.TARGET }} # --no-default-features + targets: ${{ matrix.target }} + - name: Build + run: cargo build --release --locked --target ${{ matrix.target }} - name: Prepare release assets shell: bash run: | @@ -154,122 +121,119 @@ jobs: OUT_DIR=release/completions/ cargo run --release --bin git-cliff-completions OUT_DIR=release/man/ cargo run --release --bin git-cliff-mangen for bin in 'git-cliff' 'git-cliff-completions' 'git-cliff-mangen'; do - if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then + if [ "${{ contains(matrix.os, 'windows') }}" = "true" ]; then bin="${bin}.exe" fi - cp "target/${{ matrix.build.TARGET }}/release/${bin}" release/ + cp "target/${{ matrix.target }}/release/${bin}" release/ done mv release/ git-cliff-${{ env.RELEASE_VERSION }}/ - name: Create release artifacts shell: bash run: | - if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then - 7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \ + if [ "${{ contains(matrix.os, 'windows') }}" = "true" ]; then + 7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.zip" \ git-cliff-${{ env.RELEASE_VERSION }}/ else - tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \ + tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz \ git-cliff-${{ env.RELEASE_VERSION }}/ - shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \ - > git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz.sha512 + shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz \ + > git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz.sha512 fi - name: Sign the release - if: matrix.build.OS == 'ubuntu-22.04' || matrix.build.OS == 'macos-14' + if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') run: | echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \ --passphrase-fd 0 --import private.key echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \ --passphrase-fd 0 --detach-sign \ - git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz + git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz - name: Publish to GitHub if: ${{ !contains(github.ref, '-') }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}* + file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}* file_glob: true overwrite: true tag: ${{ github.ref }} release_name: "Release v${{ env.RELEASE_VERSION }}" body: "${{ needs.generate-changelog.outputs.release_body }}" - name: Publish to GitHub (pre-release) - if: ${{ contains(github.ref, '-') }} + if: contains(github.ref, '-') uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}* + file: git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}* file_glob: true overwrite: true tag: ${{ github.ref }} release_name: "Pre-release v${{ env.RELEASE_VERSION }}" prerelease: true - name: Install node - if: matrix.build.NPM_PUBLISH == true + if: matrix.publish_npm uses: actions/setup-node@v4 with: node-version: 18 registry-url: "https://registry.npmjs.org" - name: Publish to NPM - if: matrix.build.NPM_PUBLISH == true + if: matrix.publish_npm shell: bash run: | cd npm bin="git-cliff" - node_os=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1) + node_os=$(echo "${{ matrix.name }}" | cut -d '-' -f1) export node_os - node_arch=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2) + node_arch=$(echo "${{ matrix.name }}" | cut -d '-' -f2) export node_arch export version="${{ env.RELEASE_VERSION }}" - if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then + if [ "${{ contains(matrix.os, 'windows') }}" = "true" ]; then export node_pkg="${bin}-windows-${node_arch}" else export node_pkg="${bin}-${node_os}-${node_arch}" fi mkdir -p "${node_pkg}/bin" envsubst < package.json.tmpl > "${node_pkg}/package.json" - if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then + if [ "${{ contains(matrix.os, 'windows') }}" = "true" ]; then bin="${bin}.exe" fi - cp "../target/${{ matrix.build.TARGET }}/release/${bin}" "${node_pkg}/bin" + cp "../target/${{ matrix.target }}/release/${bin}" "${node_pkg}/bin" cp ../README.md "${node_pkg}" cd "${node_pkg}" npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Build Python wheels (linux) - if: matrix.build.PYPI_PUBLISH == true && startsWith(matrix.build.NAME, 'linux') + if: matrix.publish_pypi && startsWith(matrix.name, 'linux') uses: PyO3/maturin-action@v1 with: working-directory: pypi - target: ${{ matrix.build.TARGET }} + target: ${{ matrix.target }} args: --release --sdist --out wheels sccache: "true" # https://github.com/PyO3/maturin-action/issues/245 - manylinux: ${{ matrix.build.TARGET == 'aarch64-unknown-linux-gnu' && '2_28' || 'auto' }} + manylinux: ${{ matrix.target == 'aarch64-unknown-linux-gnu' && '2_28' || 'auto' }} - name: Build Python wheels (macos & windows) - if: | - matrix.build.PYPI_PUBLISH == true && - (startsWith(matrix.build.OS, 'macos') || startsWith(matrix.build.OS, 'windows')) + if: matrix.publish_pypi && (contains(matrix.os, 'macos') || contains(matrix.os, 'windows')) uses: PyO3/maturin-action@v1 with: working-directory: pypi - target: ${{ matrix.build.TARGET }} + target: ${{ matrix.target }} args: --release --sdist --out wheels sccache: "true" - name: Build Python wheels (musl) - if: matrix.build.PYPI_PUBLISH == true && endsWith(matrix.build.OS, 'musl') + if: matrix.publish_pypi && matrix.install_musl uses: PyO3/maturin-action@v1 with: working-directory: pypi - target: ${{ matrix.build.TARGET }} + target: ${{ matrix.target }} args: --release --sdist --out wheels sccache: "true" manylinux: musllinux_1_2 - name: Upload Python wheels uses: actions/upload-artifact@v4 with: - name: "wheels-${{ matrix.build.TARGET }}" - working-directory: pypi + name: "wheels-${{ matrix.target }}" path: pypi/wheels publish-npm: