From eeefac1ace137016339d67ad997ebd3e229a81b9 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 6 Apr 2024 23:16:16 -0400 Subject: [PATCH] Update to latest release workflow --- .github/workflows/build-binaries.yml | 184 +++------------------------ .github/workflows/release.yml | 65 +++++----- Cargo.toml | 29 +++-- 3 files changed, 72 insertions(+), 206 deletions(-) diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 106ec58b0ae65d..91ccc529dc0e68 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -78,7 +78,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: x86_64 - args: --release --locked --out dist --features self-update + args: --release --locked --out dist - name: "Upload wheels" uses: actions/upload-artifact@v4 with: @@ -119,7 +119,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: aarch64 - args: --release --locked --out dist --features self-update + args: --release --locked --out dist - name: "Test wheel - aarch64" run: | pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall @@ -158,6 +158,8 @@ jobs: arch: x64 - target: i686-pc-windows-msvc arch: x86 + - target: aarch64-pc-windows-msvc + arch: x64 steps: - uses: actions/checkout@v4 with: @@ -172,7 +174,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --locked --out dist --features self-update + args: --release --locked --out dist env: # aarch64 build fails, see https://github.com/PyO3/maturin/issues/2110 XWIN_VERSION: 16 @@ -225,22 +227,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: auto - args: --release --locked --out dist --features self-update - # See: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145 - before-script-linux: | - # If we're running on rhel centos, install needed packages. - if command -v yum &> /dev/null; then - yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic - - # If we're running on i686 we need to symlink libatomic - # in order to build openssl with -latomic flag. - if [[ ! -d "/usr/lib64" ]]; then - ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so - fi - else - # If we're running on debian-based system. - apt update -y && apt-get install -y libssl-dev openssl pkg-config - fi + args: --release --locked --out dist - name: "Test wheel" if: ${{ startsWith(matrix.target, 'x86_64') }} run: | @@ -273,7 +260,7 @@ jobs: *.tar.gz *.sha256 - linux-arm: + linux-cross: if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} runs-on: ubuntu-latest strategy: @@ -286,144 +273,18 @@ jobs: maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 - target: armv7-unknown-linux-gnueabihf arch: armv7 - - target: arm-unknown-linux-musleabihf - arch: arm - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: "Prep README.md" - run: python scripts/transform_readme.py --target pypi - - name: "Build wheels" - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - # On `aarch64`, use `manylinux: 2_28`; otherwise, use `manylinux: auto`. - manylinux: ${{ matrix.platform.arch == 'aarch64' && '2_28' || 'auto' }} - docker-options: ${{ matrix.platform.maturin_docker_options }} - args: --release --locked --out dist --features self-update - - uses: uraimo/run-on-arch-action@v2 - name: Test wheel - with: - arch: ${{ matrix.platform.arch == 'arm' && 'armv6' || matrix.platform.arch }} - distro: ${{ matrix.platform.arch == 'arm' && 'bullseye' || 'ubuntu20.04' }} - githubToken: ${{ github.token }} - install: | - apt-get update - apt-get install -y --no-install-recommends python3 python3-pip - pip3 install -U pip - run: | - pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - ${{ env.MODULE_NAME }} --help - - name: "Upload wheels" - uses: actions/upload-artifact@v4 - with: - name: wheels-${{ matrix.platform.target }} - path: dist - - name: "Archive binary" - shell: bash - run: | - set -euo pipefail - - TARGET=${{ matrix.platform.target }} - ARCHIVE_NAME=ruff-$TARGET - ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz - - mkdir -p $ARCHIVE_NAME - cp target/$TARGET/release/ruff $ARCHIVE_NAME/ruff - tar czvf $ARCHIVE_FILE $ARCHIVE_NAME - shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 - - name: "Upload binary" - uses: actions/upload-artifact@v4 - with: - name: artifacts-${{ matrix.platform.target }} - path: | - *.tar.gz - *.sha256 - - # Like `linux-arm`, but use `--no-default-features --features flate2/rust_backend` when - # building ruff. - linux-s390x: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} - runs-on: ubuntu-latest - strategy: - matrix: - platform: - target: s390x-unknown-linux-gnu arch: s390x - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: "Prep README.md" - run: python scripts/transform_readme.py --target pypi - - name: "Build wheels" - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - manylinux: auto - docker-options: ${{ matrix.platform.maturin_docker_options }} - args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features self-update - - uses: uraimo/run-on-arch-action@v2 - if: matrix.platform.arch != 'ppc64' - name: Test wheel - with: - arch: ${{ matrix.platform.arch }} - distro: ubuntu20.04 - githubToken: ${{ github.token }} - install: | - apt-get update - apt-get install -y --no-install-recommends python3 python3-pip - pip3 install -U pip - run: | - pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - ${{ env.MODULE_NAME }} --help - - name: "Upload wheels" - uses: actions/upload-artifact@v4 - with: - name: wheels-${{ matrix.platform.target }} - path: dist - - name: "Archive binary" - shell: bash - run: | - set -euo pipefail - - TARGET=${{ matrix.platform.target }} - ARCHIVE_NAME=ruff-$TARGET - ARCHIVE_FILE=$ARCHIVE_NAME.tar.gz - - mkdir -p $ARCHIVE_NAME - cp target/$TARGET/release/ruff $ARCHIVE_NAME/ruff - tar czvf $ARCHIVE_FILE $ARCHIVE_NAME - shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256 - - name: "Upload binary" - uses: actions/upload-artifact@v4 - with: - name: artifacts-${{ matrix.platform.target }} - path: | - *.tar.gz - *.sha256 - - # Like `linux-arm`, but use `--no-default-features --features flate2/rust_backend` when - # building ruff, and install the `gcc-powerpc64-linux-gnu` package. - linux-powerpc: - if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-build') }} - runs-on: ubuntu-latest - strategy: - matrix: - platform: - target: powerpc64le-unknown-linux-gnu arch: ppc64le + # see https://github.com/astral-sh/ruff/issues/10073 + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 - target: powerpc64-unknown-linux-gnu arch: ppc64 + # see https://github.com/astral-sh/ruff/issues/10073 + maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16 + - target: arm-unknown-linux-musleabihf + arch: arm steps: - uses: actions/checkout@v4 @@ -440,20 +301,13 @@ jobs: target: ${{ matrix.platform.target }} manylinux: auto docker-options: ${{ matrix.platform.maturin_docker_options }} - args: --release --locked --out dist --no-default-features --features flate2/rust_backend --features self-update - before-script-linux: | - if command -v yum &> /dev/null; then - yum update -y - yum -y install epel-release - yum repolist - yum install -y gcc-powerpc64-linux-gnu - fi + args: --release --locked --out dist - uses: uraimo/run-on-arch-action@v2 if: matrix.platform.arch != 'ppc64' name: Test wheel with: - arch: ${{ matrix.platform.arch }} - distro: ubuntu20.04 + arch: ${{ matrix.platform.arch == 'arm' && 'armv6' || matrix.platform.arch }} + distro: ${{ matrix.platform.arch == 'arm' && 'bullseye' || 'ubuntu20.04' }} githubToken: ${{ github.token }} install: | apt-get update @@ -461,7 +315,7 @@ jobs: pip3 install -U pip run: | pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - ${{ env.MODULE_NAME }} --help + ruff --help - name: "Upload wheels" uses: actions/upload-artifact@v4 with: @@ -511,7 +365,7 @@ jobs: with: target: ${{ matrix.target }} manylinux: musllinux_1_2 - args: --release --locked --out dist --features self-update + args: --release --locked --out dist - name: "Test wheel" if: matrix.target == 'x86_64-unknown-linux-musl' uses: addnab/docker-run-action@v3 @@ -575,7 +429,7 @@ jobs: with: target: ${{ matrix.platform.target }} manylinux: musllinux_1_2 - args: --release --locked --out dist --features self-update + args: --release --locked --out dist docker-options: ${{ matrix.platform.maturin_docker_options }} - uses: uraimo/run-on-arch-action@v2 name: Test wheel diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4895307fa6720..f0de4cd9c769d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -# Copyright 2022-2023, axodotdev +# Copyright 2022-2024, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # # CI that: @@ -6,9 +6,9 @@ # * checks for a Git Tag that looks like a release # * builds artifacts with cargo-dist (archives, installers, hashes) # * uploads those artifacts to temporary workflow zip -# * on success, uploads the artifacts to a Github Release +# * on success, uploads the artifacts to a GitHub Release # -# Note that the Github Release will be created with a generated +# Note that the GitHub Release will be created with a generated # title/body based on your changelogs. name: Release @@ -31,7 +31,7 @@ permissions: # packages versioned/released in lockstep). # # If you push multiple tags at once, separate instances of this workflow will -# spin up, creating an independent announcement for each one. However Github +# spin up, creating an independent announcement for each one. However, GitHub # will hard limit this to 3 tags per commit, as it will assume more tags is a # mistake. # @@ -65,7 +65,7 @@ jobs: # we specify bash to get pipefail; it guards against the `curl` command # failing. otherwise `sh` won't catch that `curl` returned non-0 shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.7.3-prerelease.3/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0/cargo-dist-installer.sh | sh" # sure would be cool if github gave us proper conditionals... # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible # functionality based on whether this is a pull_request, and whether it's from a fork. @@ -73,15 +73,15 @@ jobs: # but also really annoying to build CI around when it needs secrets to work right.) - id: plan run: | - cargo dist ${{ inputs.tag && (inputs.tag != 'dry-run' && format('host --steps=create --tag={0}', inputs.tag) || format('host --steps=create', inputs.tag)) || (github.event.pull_request.head.repo.fork && 'plan' || 'host --steps=check') }} --output-format=json > dist-manifest.json + cargo dist ${{ (inputs.tag && inputs.tag != 'dry-run' && format('host --steps=create --tag={0}', inputs.tag)) || 'plan' }} --output-format=json > plan-dist-manifest.json echo "cargo dist ran successfully" - cat dist-manifest.json - echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" + cat plan-dist-manifest.json + echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: artifacts - path: dist-manifest.json + name: artifacts-plan-dist-manifest + path: plan-dist-manifest.json custom-build-binaries: needs: @@ -116,13 +116,15 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.7.3-prerelease.3/cargo-dist-installer.sh | sh" + shell: bash + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0/cargo-dist-installer.sh | sh" # Get all the local artifacts for the global tasks to use (for e.g. checksums) - name: Fetch local artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: artifacts + pattern: artifacts-* path: target/distrib/ + merge-multiple: true - id: cargo-dist shell: bash run: | @@ -131,14 +133,14 @@ jobs: # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" cp dist-manifest.json "$BUILD_MANIFEST_NAME" - name: "Upload artifacts" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: artifacts + name: artifacts-build-global path: | ${{ steps.cargo-dist.outputs.paths }} ${{ env.BUILD_MANIFEST_NAME }} @@ -146,9 +148,11 @@ jobs: host: needs: - plan + - custom-build-binaries + - custom-build-docker - build-global-artifacts # Only run if we're "publishing", and only if local and global didn't fail (skipped is fine) - if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') }} + if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.custom-build-binaries.result == 'skipped' || needs.custom-build-binaries.result == 'success') && (needs.custom-build-docker.result == 'skipped' || needs.custom-build-docker.result == 'success') }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} runs-on: "ubuntu-20.04" @@ -159,14 +163,15 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.7.3-prerelease.3/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.14.0/cargo-dist-installer.sh | sh" # Fetch artifacts from scratch-storage - name: Fetch artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: artifacts + pattern: artifacts-* path: target/distrib/ - # This is a harmless no-op for Github Releases, hosting for that happens in "announce" + merge-multiple: true + # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce" - id: host shell: bash run: | @@ -175,9 +180,10 @@ jobs: cat dist-manifest.json echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" - name: "Upload dist-manifest.json" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: artifacts + # Overwrite the previous copy + name: artifacts-dist-manifest path: dist-manifest.json custom-publish-pypi: @@ -194,7 +200,7 @@ jobs: id-token: write packages: write - # Create a Github Release while uploading all files to it + # Create a GitHub Release while uploading all files to it announce: needs: - plan @@ -211,16 +217,17 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - name: "Download Github Artifacts" - uses: actions/download-artifact@v3 + - name: "Download GitHub Artifacts" + uses: actions/download-artifact@v4 with: - name: artifacts + pattern: artifacts-* path: artifacts + merge-multiple: true - name: Cleanup run: | # Remove the granular manifests rm -f artifacts/*-dist-manifest.json - - name: Create Github Release + - name: Create GitHub Release uses: ncipollo/release-action@v1 with: tag: ${{ needs.plan.outputs.tag }} diff --git a/Cargo.toml b/Cargo.toml index 3bb75e19cdd9a5..e60f9334d726b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -227,7 +227,7 @@ inherits = "release" # Config for 'cargo dist' [workspace.metadata.dist] # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.7.3-prerelease.3" +cargo-dist-version = "0.14.0" # CI backends to support ci = ["github"] # The installers to generate for each app @@ -238,23 +238,24 @@ windows-archive = ".zip" unix-archive = ".tar.gz" # Target platforms to build apps for (Rust target-triple syntax) targets = [ - "aarch64-unknown-linux-gnu", - "x86_64-unknown-linux-gnu", - "i686-unknown-linux-gnu", "aarch64-apple-darwin", - "x86_64-apple-darwin", - "aarch64-unknown-linux-musl", - "x86_64-unknown-linux-musl", - "i686-unknown-linux-musl", "aarch64-pc-windows-msvc", - "x86_64-pc-windows-msvc", - "i686-pc-windows-msvc", + "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", "armv7-unknown-linux-gnueabihf", + "armv7-unknown-linux-musleabihf", + "i686-pc-windows-msvc", + "i686-unknown-linux-gnu", + "i686-unknown-linux-musl", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", - "s390x-unknown-linux-gnu" + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", ] -# Whether to auto-include files like READMEs and CHANGELOGs (default true) +# Whether to auto-include files like READMEs, LICENSEs, and CHANGELOGs (default true) auto-includes = false # Whether cargo-dist should create a Github Release or use an existing draft create-release = true @@ -270,3 +271,7 @@ local-artifacts-jobs = ["./build-binaries", "./build-docker"] publish-jobs = ["./publish-pypi"] # Announcement jobs to run in CI post-announce-jobs = ["./notify-dependents"] +# Skip checking whether the specified configuration files are up to date +#allow-dirty = ["ci"] +# Whether to install an updater program +install-updater = false