From 8629468e45657dd563a3b84978b9793a9048841e Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Sat, 20 Dec 2025 18:53:36 -0500 Subject: [PATCH] ci: use scripts in more places in CI (#1906) * move cirrus release script * update a few other places --- .github/workflows/build_releases.yml | 14 +++++++++---- .github/workflows/ci.yml | 8 ------- .github/workflows/coverage.yml | 4 +--- .github/workflows/deployment.yml | 7 ++----- .github/workflows/docs.yml | 6 +----- .github/workflows/post_release.yml | 21 ++++--------------- .../release.py => ci/cirrus_release.py} | 0 scripts/ci/configure_git.sh | 6 ++++++ scripts/ci/generate_choco.sh | 11 ++++++++++ scripts/ci/release_choco.sh | 6 ++++++ scripts/ci/release_stable_docs.sh | 8 +++++++ 11 files changed, 49 insertions(+), 42 deletions(-) rename scripts/{cirrus/release.py => ci/cirrus_release.py} (100%) create mode 100755 scripts/ci/configure_git.sh create mode 100755 scripts/ci/generate_choco.sh create mode 100755 scripts/ci/release_choco.sh create mode 100755 scripts/ci/release_stable_docs.sh diff --git a/.github/workflows/build_releases.yml b/.github/workflows/build_releases.yml index a52c12a7..4c09c462 100644 --- a/.github/workflows/build_releases.yml +++ b/.github/workflows/build_releases.yml @@ -5,6 +5,8 @@ # - MSI installer for Windows (.msi) # - .deb releases # - .rpm releases +# +# TODO: Break this up into scripts instead. name: "build releases" @@ -79,7 +81,11 @@ jobs: } # macOS (x86-64 and aarch64) - - { os: "macos-15-intel", target: "x86_64-apple-darwin", cross: false } + - { + os: "macos-15-intel", + target: "x86_64-apple-darwin", + cross: false, + } - { os: "macos-15", target: "aarch64-apple-darwin", cross: false } # Windows (x86-64, x86) @@ -322,12 +328,12 @@ jobs: - { os: "windows-2022", target: "x86_64-pc-windows-msvc", - output: "bottom_x86_64_installer.msi" + output: "bottom_x86_64_installer.msi", } - { os: "windows-11-arm", target: "aarch64-pc-windows-msvc", - output: "bottom_aarch64_installer.msi" + output: "bottom_aarch64_installer.msi", } runs-on: ${{ matrix.info.os }} steps: @@ -416,7 +422,7 @@ jobs: raw=$(git branch -r --contains '${{ github.ref_name }}'); BRANCH=${raw##*/}; fi - python ./scripts/cirrus/release.py "$BRANCH" "release/" "${{ inputs.caller }}" + python ./scripts/ci/cirrus_release.py "$BRANCH" "release/" "${{ inputs.caller }}" - name: Generate artifact attestation for file uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cac4d1db..b6789849 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,14 +6,6 @@ # - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml # - https://www.reillywood.com/blog/rust-faster-ci/ # - https://matklad.github.io/2021/09/04/fast-rust-builds.html -# -# Supported platforms run the following tasks: -# - Format -# - Test (built/test in separate steps) -# - Clippy (apparently faster to do it after the build/test) -# -# Unsupported platforms run the following tasks: -# - Clippy name: ci diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2c7e4fec..f2ebcc96 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -74,12 +74,10 @@ jobs: cargo install cargo-llvm-cov --version 0.6.11 --locked - name: Generate code coverage - run: | - cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info --locked --target=${{ matrix.info.target }} + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info --locked --target=${{ matrix.info.target }} # The token is generally not needed, but sometimes the default shared token hits limits. # Yes this is ugly as hell. Why this is not a built-in feature of GHA, I have no idea. - - name: Upload to codecov.io (Attempt 1) id: upload_attempt_1 uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index e2b872e1..62bb54a6 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -75,14 +75,11 @@ jobs: merge-multiple: true - name: Execute choco packaging script - run: | - python "./scripts/windows/choco/choco_packager.py" "./release/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./scripts/windows/choco/bottom.nuspec.template" "./scripts/windows/choco/chocolateyinstall.ps1.template" "bottom.nuspec" "tools/chocolateyinstall.ps1" "tools/" - zip -r choco.zip "bottom.nuspec" "tools" + run: ./scripts/ci/generate_choco.sh - name: Move release file into release directory shell: bash - run: | - mv choco.zip release/ + run: mv choco.zip release/ - name: Save release as artifact uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2499e5c0..5580dc51 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -34,11 +34,7 @@ jobs: run: pip install -r docs/requirements.txt - name: Configure git user and email - run: | - git config --global user.name ${GIT_USER} - git config --global user.email ${GIT_EMAIL} - echo Name: $(git config --get user.name) - echo Email: $(git config --get user.email) + run: ./scripts/ci/configure_git.sh - name: Build and deploy docs with mike run: | diff --git a/.github/workflows/post_release.yml b/.github/workflows/post_release.yml index 11e4843a..dc3d3f26 100644 --- a/.github/workflows/post_release.yml +++ b/.github/workflows/post_release.yml @@ -67,20 +67,10 @@ jobs: run: pip install -r docs/requirements.txt - name: Configure git user and email - run: | - git config --global user.name ${GIT_USER} - git config --global user.email ${GIT_EMAIL} - echo Name: $(git config --get user.name) - echo Email: $(git config --get user.email) + run: ./scripts/ci/configure_git.sh - name: Build and deploy docs with mike as the latest stable branch - run: | - cd docs - OLD_STABLE_VERSION=$(mike list stable | grep -Po '([0-9]+.[0-9]+.[0-9]+)' | head -n1) - echo ${OLD_STABLE_VERSION} - mike retitle --push stable ${OLD_STABLE_VERSION} - mike deploy --push --update-aliases ${RELEASE_VERSION} stable - mike retitle --push ${RELEASE_VERSION} "${RELEASE_VERSION} (stable)" + run: ./scripts/ci/release_stable_docs.sh chocolatey: needs: [initialize] @@ -94,9 +84,6 @@ jobs: - name: Validate release version run: | echo "Release version: ${{ env.RELEASE_VERSION }}" + - name: Trigger choco - run: | - curl -X POST https://api.github.com/repos/ClementTsang/choco-bottom/dispatches \ - -H 'Accept: application/vnd.github.everest-preview+json' \ - -u ${{ secrets.BOTTOM_PACKAGE_DEPLOYMENT }} \ - --data '{ "event_type": "update", "client_payload": { "version": "'"$RELEASE_VERSION"'" } }' + run: ./scripts/ci/release_choco.sh diff --git a/scripts/cirrus/release.py b/scripts/ci/cirrus_release.py similarity index 100% rename from scripts/cirrus/release.py rename to scripts/ci/cirrus_release.py diff --git a/scripts/ci/configure_git.sh b/scripts/ci/configure_git.sh new file mode 100755 index 00000000..64602b09 --- /dev/null +++ b/scripts/ci/configure_git.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +git config --global user.name ${GIT_USER} +git config --global user.email ${GIT_EMAIL} +echo Name: $(git config --get user.name) +echo Email: $(git config --get user.email) diff --git a/scripts/ci/generate_choco.sh b/scripts/ci/generate_choco.sh new file mode 100755 index 00000000..7fd010a1 --- /dev/null +++ b/scripts/ci/generate_choco.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +python "./scripts/windows/choco/choco_packager.py" \ + "./release/bottom_x86_64-pc-windows-msvc.zip" \ + ${{ env.RELEASE_VERSION }} \ + "./scripts/windows/choco/bottom.nuspec.template" \ + "./scripts/windows/choco/chocolateyinstall.ps1.template" \ + "bottom.nuspec" \ + "tools/chocolateyinstall.ps1" \ + "tools/" +zip -r choco.zip "bottom.nuspec" "tools" \ No newline at end of file diff --git a/scripts/ci/release_choco.sh b/scripts/ci/release_choco.sh new file mode 100755 index 00000000..937f79e1 --- /dev/null +++ b/scripts/ci/release_choco.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +curl -X POST https://api.github.com/repos/ClementTsang/choco-bottom/dispatches \ + -H 'Accept: application/vnd.github.everest-preview+json' \ + -u ${{ secrets.BOTTOM_PACKAGE_DEPLOYMENT }} \ + --data '{ "event_type": "update", "client_payload": { "version": "'"$RELEASE_VERSION"'" } }' diff --git a/scripts/ci/release_stable_docs.sh b/scripts/ci/release_stable_docs.sh new file mode 100755 index 00000000..c68e2231 --- /dev/null +++ b/scripts/ci/release_stable_docs.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +cd docs +OLD_STABLE_VERSION=$(mike list stable | grep -Po '([0-9]+.[0-9]+.[0-9]+)' | head -n1) +echo ${OLD_STABLE_VERSION} +mike retitle --push stable ${OLD_STABLE_VERSION} +mike deploy --push --update-aliases ${RELEASE_VERSION} stable +mike retitle --push ${RELEASE_VERSION} "${RELEASE_VERSION} (stable)"