From 95db2c3353a2551a36ee6155ecccd62652b1e52e Mon Sep 17 00:00:00 2001 From: beeb <703631+beeb@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:13:36 +0100 Subject: [PATCH 1/5] chore: disable release-plz github releases --- release-plz.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/release-plz.toml b/release-plz.toml index 26ffbf1..ff01bbd 100644 --- a/release-plz.toml +++ b/release-plz.toml @@ -1,3 +1,4 @@ [workspace] changelog_config = "cliff.toml" dependencies_update = true +git_release_enable = false # will use cargo-dist for that From ceeb756a231b086e7cf8e0ed13dba78933c53272 Mon Sep 17 00:00:00 2001 From: beeb <703631+beeb@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:19:55 +0100 Subject: [PATCH 2/5] ci: update release-plz workflow --- .github/workflows/build.yml | 236 -------------------------- .github/workflows/build_dispatch.yml | 170 ------------------- .github/workflows/clean-artifacts.yml | 20 --- .github/workflows/release-plz.yml | 43 ++++- 4 files changed, 39 insertions(+), 430 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/build_dispatch.yml delete mode 100644 .github/workflows/clean-artifacts.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 0aff3c3..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,236 +0,0 @@ -name: Release builds - -on: - release: - types: [published] - -jobs: - build-windows: - runs-on: windows-latest - name: Release build for Windows - steps: - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: actions/checkout@v4 - - name: Build release binary - run: cargo build --release - env: - RUSTFLAGS: '-C target-feature=+crt-static' - - uses: actions/upload-artifact@v4 - with: - name: awsbck-windows - path: target/release/awsbck.exe - - build-macos: - runs-on: macos-13 - name: Release build for macOS - steps: - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: actions/checkout@v4 - - name: Build release binary - run: cargo build --release - env: - LZMA_API_STATIC: 'true' - - uses: actions/upload-artifact@v4 - with: - name: awsbck-macos - path: target/release/awsbck - - build-macos-arm: - runs-on: macos-13 - name: Release build for macOS aarch64 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '14.3' - - uses: dtolnay/rust-toolchain@stable - with: - targets: aarch64-apple-darwin - - uses: Swatinem/rust-cache@v2 - - uses: actions/checkout@v4 - - name: Build release binary - run: | - SDKROOT=$(xcrun -sdk macosx13.3 --show-sdk-path) \ - MACOS_DEPLOYMENT_TARGET=$(xcrun -sdk macosx13.3 --show-sdk-platform-version) \ - cargo build --release --target=aarch64-apple-darwin - env: - LZMA_API_STATIC: 'true' - - uses: actions/upload-artifact@v4 - with: - name: awsbck-macos-aarch64 - path: target/aarch64-apple-darwin/release/awsbck - - build-linux: - runs-on: ubuntu-latest - name: Release build for linux x86_64 - steps: - - uses: dtolnay/rust-toolchain@stable - with: - targets: x86_64-unknown-linux-musl - - uses: Swatinem/rust-cache@v2 - - name: Install musl tools - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends musl-tools - - uses: actions/checkout@v4 - - name: Build release binary - run: cargo build --release --target x86_64-unknown-linux-musl - - uses: actions/upload-artifact@v4 - with: - name: awsbck-linux - path: target/x86_64-unknown-linux-musl/release/awsbck - - build-arm: - name: Release builds for linux ARM - runs-on: ubuntu-latest - strategy: - matrix: - include: - - target: aarch64-unknown-linux-musl - arch: aarch64 - - target: armv7-unknown-linux-gnueabihf - arch: armv7 - steps: - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - uses: Swatinem/rust-cache@v2 - - run: cargo install cross --git https://github.com/cross-rs/cross - - uses: actions/checkout@v4 - - run: cross build --release --target ${{ matrix.target }} - - uses: actions/upload-artifact@v4 - with: - name: awsbck-${{ matrix.arch }} - path: target/${{ matrix.target }}/release/awsbck - - build-docker: - needs: [build-linux, build-arm] - name: Create docker container - runs-on: ubuntu-latest - permissions: - packages: write - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - uses: actions/download-artifact@v4 - with: - name: awsbck-linux - path: linux_amd64/awsbck - - uses: actions/download-artifact@v4 - with: - name: awsbck-aarch64 - path: linux_arm64/awsbck - - uses: actions/download-artifact@v4 - with: - name: awsbck-armv7 - path: linux_arm/awsbck - - name: Login to Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker metadata for root image - id: meta-root - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository_owner }}/awsbck - flavor: | - latest=false - tags: | - type=semver,pattern=root-{{version}} - type=semver,pattern=root-{{major}}.{{minor}} - type=raw,value=root-latest - - name: Build and push for root image - uses: docker/build-push-action@v6 - with: - push: true - context: . - file: Dockerfile.root - tags: ${{ steps.meta-root.outputs.tags }} - labels: ${{ steps.meta-root.outputs.labels }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - - name: Docker metadata # generates tags (version number and "latest") and labels - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository_owner }}/awsbck - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - name: Build and push - uses: docker/build-push-action@v6 - with: - push: true - context: . - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 - - update-release: - needs: [build-linux, build-arm, build-windows, build-macos, build-macos-arm] - name: Update GitHub release - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - name: extract version from Cargo.toml - uses: SebRollen/toml-action@v1.2.0 - id: version - with: - file: Cargo.toml - field: package.version - - name: download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - name: create release directory - run: mkdir release - - name: create release files - run: | - tar -C ./artifacts/awsbck-linux -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-x64.tar.gz awsbck - tar -C ./artifacts/awsbck-aarch64 -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-aarch64.tar.gz awsbck - tar -C ./artifacts/awsbck-armv7 -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-armv7.tar.gz awsbck - zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-windows.zip ./artifacts/awsbck-windows/awsbck.exe - zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-macos.zip ./artifacts/awsbck-macos/awsbck - zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-macos-aarch64.zip ./artifacts/awsbck-macos-aarch64/awsbck - - name: upload linux-x64 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-linux-x64.tar.gz - tag: ${{ github.ref }} - - name: upload linux-aarch64 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-linux-aarch64.tar.gz - tag: ${{ github.ref }} - - name: upload linux-armv7 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-linux-armv7.tar.gz - tag: ${{ github.ref }} - - name: upload windows to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-windows.zip - tag: ${{ github.ref }} - - name: upload macos to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-macos.zip - tag: ${{ github.ref }} - - name: upload macos-aarch64 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-macos-aarch64.zip - tag: ${{ github.ref }} diff --git a/.github/workflows/build_dispatch.yml b/.github/workflows/build_dispatch.yml deleted file mode 100644 index 1ed07e1..0000000 --- a/.github/workflows/build_dispatch.yml +++ /dev/null @@ -1,170 +0,0 @@ -name: Release builds (dispatch) - -on: - workflow_dispatch: - -jobs: - build-windows: - runs-on: windows-latest - name: Release build for Windows - steps: - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: actions/checkout@v4 - - name: Build release binary - run: cargo build --release - env: - RUSTFLAGS: '-C target-feature=+crt-static' - - uses: actions/upload-artifact@v4 - with: - name: awsbck-windows - path: target/release/awsbck.exe - - build-macos: - runs-on: macos-13 - name: Release build for macOS - steps: - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: actions/checkout@v4 - - name: Build release binary - run: cargo build --release - env: - LZMA_API_STATIC: 'true' - - uses: actions/upload-artifact@v4 - with: - name: awsbck-macos - path: target/release/awsbck - - build-macos-arm: - runs-on: macos-13 - name: Release build for macOS aarch64 - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '14.3' - - uses: dtolnay/rust-toolchain@stable - with: - targets: aarch64-apple-darwin - - uses: Swatinem/rust-cache@v2 - - uses: actions/checkout@v4 - - name: Build release binary - run: | - SDKROOT=$(xcrun -sdk macosx13.3 --show-sdk-path) \ - MACOS_DEPLOYMENT_TARGET=$(xcrun -sdk macosx13.3 --show-sdk-platform-version) \ - cargo build --release --target=aarch64-apple-darwin - env: - LZMA_API_STATIC: 'true' - - uses: actions/upload-artifact@v4 - with: - name: awsbck-macos-aarch64 - path: target/aarch64-apple-darwin/release/awsbck - - build-linux: - runs-on: ubuntu-latest - name: Release build for linux x86_64 - steps: - - uses: dtolnay/rust-toolchain@stable - with: - targets: x86_64-unknown-linux-musl - - uses: Swatinem/rust-cache@v2 - - name: Install musl tools - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends musl-tools - - uses: actions/checkout@v4 - - name: Build release binary - run: cargo build --release --target x86_64-unknown-linux-musl - - uses: actions/upload-artifact@v4 - with: - name: awsbck-linux - path: target/x86_64-unknown-linux-musl/release/awsbck - - build-arm: - name: Release builds for linux ARM - runs-on: ubuntu-latest - strategy: - matrix: - include: - - target: aarch64-unknown-linux-musl - arch: aarch64 - - target: armv7-unknown-linux-gnueabihf - arch: armv7 - steps: - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - uses: Swatinem/rust-cache@v2 - - run: cargo install cross --git https://github.com/cross-rs/cross - - uses: actions/checkout@v4 - - run: cross build --release --target ${{ matrix.target }} - - uses: actions/upload-artifact@v4 - with: - name: awsbck-${{ matrix.arch }} - path: target/${{ matrix.target }}/release/awsbck - - update-release: - needs: [build-linux, build-arm, build-windows, build-macos, build-macos-arm] - name: Update GitHub release - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - name: extract version from Cargo.toml - uses: SebRollen/toml-action@v1.2.0 - id: version - with: - file: Cargo.toml - field: package.version - - name: download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - name: create release directory - run: mkdir release - - name: create release files - run: | - tar -C ./artifacts/awsbck-linux -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-x64.tar.gz awsbck - tar -C ./artifacts/awsbck-aarch64 -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-aarch64.tar.gz awsbck - tar -C ./artifacts/awsbck-armv7 -czvf ./release/awsbck-v${{ steps.version.outputs.value }}-linux-armv7.tar.gz awsbck - zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-windows.zip ./artifacts/awsbck-windows/awsbck.exe - zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-macos.zip ./artifacts/awsbck-macos/awsbck - zip -j ./release/awsbck-v${{ steps.version.outputs.value }}-macos-aarch64.zip ./artifacts/awsbck-macos-aarch64/awsbck - - name: upload linux-x64 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-linux-x64.tar.gz - tag: refs/tags/v${{ steps.version.outputs.value }} - - name: upload linux-aarch64 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-linux-aarch64.tar.gz - tag: refs/tags/v${{ steps.version.outputs.value }} - - name: upload linux-armv7 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-linux-armv7.tar.gz - tag: refs/tags/v${{ steps.version.outputs.value }} - - name: upload windows to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-windows.zip - tag: refs/tags/v${{ steps.version.outputs.value }} - - name: upload macos to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-macos.zip - tag: refs/tags/v${{ steps.version.outputs.value }} - - name: upload macos-aarch64 to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: release/awsbck-v${{ steps.version.outputs.value }}-macos-aarch64.zip - tag: refs/tags/v${{ steps.version.outputs.value }} diff --git a/.github/workflows/clean-artifacts.yml b/.github/workflows/clean-artifacts.yml deleted file mode 100644 index 6180c47..0000000 --- a/.github/workflows/clean-artifacts.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Remove old artifacts - -on: - schedule: - - cron: '23 1 * * *' # Every day at 1:23am - workflow_dispatch: - -jobs: - remove-old-artifacts: - permissions: - actions: write - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - name: Remove old artifacts - uses: c-hive/gha-remove-artifacts@v1 - with: - age: 7 days - skip-recent: 50 diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index 99d395a..20d0224 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -10,10 +10,12 @@ on: - main jobs: - release-plz: - name: Release-plz + + release-plz-release: + name: Release-plz release runs-on: ubuntu-latest - environment: Cargo + permissions: + contents: write steps: - name: Generate GitHub token uses: actions/create-github-app-token@v1 @@ -29,7 +31,40 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Run release-plz - uses: MarcoIeni/release-plz-action@v0.5 + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + release-plz-pr: + name: Release-plz PR + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - name: Generate GitHub token + uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release-pr env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} From 706600822a0fdcd49980c24082de12b712970749 Mon Sep 17 00:00:00 2001 From: beeb <703631+beeb@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:22:15 +0100 Subject: [PATCH 3/5] ci: add cargo-dist workflow --- .github/workflows/release.yml | 291 ++++++++++++++++++++++++++++++++++ Cargo.toml | 5 + dist-workspace.toml | 17 ++ 3 files changed, 313 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 dist-workspace.toml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dc9d1e7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,291 @@ +# This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/ +# +# Copyright 2022-2024, axodotdev +# SPDX-License-Identifier: MIT or Apache-2.0 +# +# CI that: +# +# * checks for a Git Tag that looks like a release +# * builds artifacts with dist (archives, installers, hashes) +# * uploads those artifacts to temporary workflow zip +# * on success, uploads the artifacts to a GitHub Release +# +# Note that the GitHub Release will be created with a generated +# title/body based on your changelogs. + +name: Release +permissions: + "contents": "write" + +# This task will run whenever you push a git tag that looks like a version +# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. +# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where +# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION +# must be a Cargo-style SemVer Version (must have at least major.minor.patch). +# +# If PACKAGE_NAME is specified, then the announcement will be for that +# package (erroring out if it doesn't have the given version or isn't dist-able). +# +# If PACKAGE_NAME isn't specified, then the announcement will be for all +# (dist-able) packages in the workspace with that version (this mode is +# intended for workspaces with only one dist-able package, or with all dist-able +# 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 +# will hard limit this to 3 tags per commit, as it will assume more tags is a +# mistake. +# +# If there's a prerelease-style suffix to the version, then the release(s) +# will be marked as a prerelease. +on: + pull_request: + push: + tags: + - '**[0-9]+.[0-9]+.[0-9]+*' + +jobs: + # Run 'dist plan' (or host) to determine what tasks we need to do + plan: + runs-on: "ubuntu-20.04" + outputs: + val: ${{ steps.plan.outputs.manifest }} + tag: ${{ !github.event.pull_request && github.ref_name || '' }} + tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} + publishing: ${{ !github.event.pull_request }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install dist + # 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.28.0/cargo-dist-installer.sh | sh" + - name: Cache dist + uses: actions/upload-artifact@v4 + with: + name: cargo-dist-cache + path: ~/.cargo/bin/dist + # 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. + # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* + # but also really annoying to build CI around when it needs secrets to work right.) + - id: plan + run: | + dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json + echo "dist ran successfully" + cat plan-dist-manifest.json + echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v4 + with: + name: artifacts-plan-dist-manifest + path: plan-dist-manifest.json + + # Build and packages all the platform-specific things + build-local-artifacts: + name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) + # Let the initial task tell us to not run (currently very blunt) + needs: + - plan + if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} + strategy: + fail-fast: false + # Target platforms/runners are computed by dist in create-release. + # Each member of the matrix has the following arguments: + # + # - runner: the github runner + # - dist-args: cli flags to pass to dist + # - install-dist: expression to run to install dist on the runner + # + # Typically there will be: + # - 1 "global" task that builds universal installers + # - N "local" tasks that build each platform's binaries and platform-specific installers + matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} + runs-on: ${{ matrix.runner }} + container: ${{ matrix.container && matrix.container.image || null }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json + steps: + - name: enable windows longpaths + run: | + git config --global core.longpaths true + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install Rust non-interactively if not already installed + if: ${{ matrix.container }} + run: | + if ! command -v cargo > /dev/null 2>&1; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + fi + - name: Install dist + run: ${{ matrix.install_dist.run }} + # Get the dist-manifest + - name: Fetch local artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - name: Install dependencies + run: | + ${{ matrix.packages_install }} + - name: Build artifacts + run: | + # Actually do builds and make zips and whatnot + dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json + echo "dist ran successfully" + - id: cargo-dist + name: Post-build + # We force bash here just because github makes it really hard to get values up + # to "real" actions without writing to env-vars, and writing to env-vars has + # inconsistent syntax between shell and powershell. + shell: bash + run: | + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: artifacts-build-local-${{ join(matrix.targets, '_') }} + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + + # Build and package all the platform-agnostic(ish) things + build-global-artifacts: + needs: + - plan + - build-local-artifacts + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cached dist + uses: actions/download-artifact@v4 + with: + name: cargo-dist-cache + path: ~/.cargo/bin/ + - run: chmod +x ~/.cargo/bin/dist + # Get all the local artifacts for the global tasks to use (for e.g. checksums) + - name: Fetch local artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - id: cargo-dist + shell: bash + run: | + dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json + echo "dist ran successfully" + + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$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@v4 + with: + name: artifacts-build-global + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + # Determines if we should publish/announce + host: + needs: + - plan + - build-local-artifacts + - 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') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: "ubuntu-20.04" + outputs: + val: ${{ steps.host.outputs.manifest }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cached dist + uses: actions/download-artifact@v4 + with: + name: cargo-dist-cache + path: ~/.cargo/bin/ + - run: chmod +x ~/.cargo/bin/dist + # Fetch artifacts from scratch-storage + - name: Fetch artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - id: host + shell: bash + run: | + dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json + echo "artifacts uploaded and released successfully" + cat dist-manifest.json + echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v4 + with: + # Overwrite the previous copy + name: artifacts-dist-manifest + path: dist-manifest.json + # Create a GitHub Release while uploading all files to it + - name: "Download GitHub Artifacts" + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: artifacts + merge-multiple: true + - name: Cleanup + run: | + # Remove the granular manifests + rm -f artifacts/*-dist-manifest.json + - name: Create GitHub Release + env: + PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}" + ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}" + ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}" + RELEASE_COMMIT: "${{ github.sha }}" + run: | + # Write and read notes from a file to avoid quoting breaking things + echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt + + gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/* + + announce: + needs: + - plan + - host + # use "always() && ..." to allow us to wait for all publish jobs while + # still allowing individual publish jobs to skip themselves (for prereleases). + # "host" however must run to completion, no skipping allowed! + if: ${{ always() && needs.host.result == 'success' }} + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive diff --git a/Cargo.toml b/Cargo.toml index 96d1ce2..3c1954f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,3 +33,8 @@ dockertest = "0.5" [profile.release] lto = "thin" strip = true + +# The profile that 'dist' will build with +[profile.dist] +inherits = "release" +lto = "thin" diff --git a/dist-workspace.toml b/dist-workspace.toml new file mode 100644 index 0000000..f25e0b3 --- /dev/null +++ b/dist-workspace.toml @@ -0,0 +1,17 @@ +[workspace] +members = ["cargo:."] + +# Config for 'dist' +[dist] +# The preferred dist version to use in CI (Cargo.toml SemVer syntax) +cargo-dist-version = "0.28.0" +# CI backends to support +ci = "github" +# The installers to generate for each app +installers = ["shell", "powershell"] +# Target platforms to build apps for (Rust target-triple syntax) +targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +# Path that installers should place binaries in +install-path = "CARGO_HOME" +# Whether to install an updater program +install-updater = false From 2594842a321e7e86187134652bee5a74dd64f325 Mon Sep 17 00:00:00 2001 From: beeb <703631+beeb@users.noreply.github.com> Date: Mon, 24 Feb 2025 19:44:21 +0100 Subject: [PATCH 4/5] ci: adjust docker workflow --- .github/workflows/docker.yml | 87 +++++++++++++++++++++++++++ .github/workflows/docker_dispatch.yml | 13 ++-- 2 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5204c22 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,87 @@ +name: Docker + +on: + workflow_dispatch: + release: + types: [published] + +permissions: + packages: write + +jobs: + docker-build: + name: Docker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - name: download binaries + uses: robinraju/release-downloader@v1.11 + id: dl + with: + latest: true + fileName: 'awsbck-*-unknown-linux-*.tar.xz' + tarBall: false + zipBall: false + - name: extract binaries + run: | + tar -xzvf awsbck-x86_64-unknown-linux-musl.tar.xz && mkdir linux_amd64 && mv awsbck linux_amd64/awsbck + tar -xzvf awsbck-aarch64-unknown-linux-gnu.tar.xz && mkdir linux_arm64 && mv awsbck linux_arm64/awsbck + - name: semver + id: semver + run: | + VERSION=$(echo "${{steps.dl.outputs.tag_name}}" | sed -e 's/^v//') + echo "version=$VERSION" >> $GITHUB_OUTPUT + MAJOR=`echo $VERSION | cut -d. -f1` + echo "major=$MAJOR" >> $GITHUB_OUTPUT + MINOR=`echo $VERSION | cut -d. -f2` + echo "minor=$MINOR" >> $GITHUB_OUTPUT + REVISION=`echo $REVISION | cut -d. -f3` + echo "revision=$REVISION" >> $GITHUB_OUTPUT + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker metadata root + id: meta-root + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/awsbck + flavor: | + latest=false + tags: | + type=raw,value=root-${{steps.semver.outputs.major}},enable=${{ steps.semver.outputs.major != '0' }} + type=raw,value=root-${{steps.semver.outputs.major}}.${{steps.semver.outputs.minor}} + type=raw,value=root-${{steps.semver.outputs.version}} + type=raw,value=root-latest + - name: Build and push root + uses: docker/build-push-action@v6 + with: + push: true + context: . + file: Dockerfile.root + tags: ${{ steps.meta-root.outputs.tags }} + labels: ${{ steps.meta-root.outputs.labels }} + platforms: linux/amd64,linux/arm64 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/awsbck + flavor: | + latest=true + tags: | + type=raw,value=${{steps.semver.outputs.major}},enable=${{ steps.semver.outputs.major != '0' }} + type=raw,value=${{steps.semver.outputs.major}}.${{steps.semver.outputs.minor}} + type=raw,value=${{steps.semver.outputs.version}} + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + context: . + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/docker_dispatch.yml b/.github/workflows/docker_dispatch.yml index f10d5ac..5204c22 100644 --- a/.github/workflows/docker_dispatch.yml +++ b/.github/workflows/docker_dispatch.yml @@ -2,6 +2,8 @@ name: Docker on: workflow_dispatch: + release: + types: [published] permissions: packages: write @@ -19,14 +21,13 @@ jobs: id: dl with: latest: true - fileName: 'awsbck-v*-linux-*.tar.gz' + fileName: 'awsbck-*-unknown-linux-*.tar.xz' tarBall: false zipBall: false - name: extract binaries run: | - tar -xzvf awsbck-v*-linux-x64.tar.gz && mkdir linux_amd64 && mv awsbck linux_amd64/awsbck - tar -xzvf awsbck-v*-linux-aarch64.tar.gz && mkdir linux_arm64 && mv awsbck linux_arm64/awsbck - tar -xzvf awsbck-v*-linux-armv7.tar.gz && mkdir linux_arm && mv awsbck linux_arm/awsbck + tar -xzvf awsbck-x86_64-unknown-linux-musl.tar.xz && mkdir linux_amd64 && mv awsbck linux_amd64/awsbck + tar -xzvf awsbck-aarch64-unknown-linux-gnu.tar.xz && mkdir linux_arm64 && mv awsbck linux_arm64/awsbck - name: semver id: semver run: | @@ -64,7 +65,7 @@ jobs: file: Dockerfile.root tags: ${{ steps.meta-root.outputs.tags }} labels: ${{ steps.meta-root.outputs.labels }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64 - name: Docker metadata id: meta uses: docker/metadata-action@v5 @@ -83,4 +84,4 @@ jobs: context: . tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64 From f0b4e5725f744737a2689d9383db3292876e5a56 Mon Sep 17 00:00:00 2001 From: beeb <703631+beeb@users.noreply.github.com> Date: Mon, 24 Feb 2025 19:45:16 +0100 Subject: [PATCH 5/5] ci: remove useless workflow --- .github/workflows/docker_dispatch.yml | 87 --------------------------- 1 file changed, 87 deletions(-) delete mode 100644 .github/workflows/docker_dispatch.yml diff --git a/.github/workflows/docker_dispatch.yml b/.github/workflows/docker_dispatch.yml deleted file mode 100644 index 5204c22..0000000 --- a/.github/workflows/docker_dispatch.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Docker - -on: - workflow_dispatch: - release: - types: [published] - -permissions: - packages: write - -jobs: - docker-build: - name: Docker - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - name: download binaries - uses: robinraju/release-downloader@v1.11 - id: dl - with: - latest: true - fileName: 'awsbck-*-unknown-linux-*.tar.xz' - tarBall: false - zipBall: false - - name: extract binaries - run: | - tar -xzvf awsbck-x86_64-unknown-linux-musl.tar.xz && mkdir linux_amd64 && mv awsbck linux_amd64/awsbck - tar -xzvf awsbck-aarch64-unknown-linux-gnu.tar.xz && mkdir linux_arm64 && mv awsbck linux_arm64/awsbck - - name: semver - id: semver - run: | - VERSION=$(echo "${{steps.dl.outputs.tag_name}}" | sed -e 's/^v//') - echo "version=$VERSION" >> $GITHUB_OUTPUT - MAJOR=`echo $VERSION | cut -d. -f1` - echo "major=$MAJOR" >> $GITHUB_OUTPUT - MINOR=`echo $VERSION | cut -d. -f2` - echo "minor=$MINOR" >> $GITHUB_OUTPUT - REVISION=`echo $REVISION | cut -d. -f3` - echo "revision=$REVISION" >> $GITHUB_OUTPUT - - name: Login to Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker metadata root - id: meta-root - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository_owner }}/awsbck - flavor: | - latest=false - tags: | - type=raw,value=root-${{steps.semver.outputs.major}},enable=${{ steps.semver.outputs.major != '0' }} - type=raw,value=root-${{steps.semver.outputs.major}}.${{steps.semver.outputs.minor}} - type=raw,value=root-${{steps.semver.outputs.version}} - type=raw,value=root-latest - - name: Build and push root - uses: docker/build-push-action@v6 - with: - push: true - context: . - file: Dockerfile.root - tags: ${{ steps.meta-root.outputs.tags }} - labels: ${{ steps.meta-root.outputs.labels }} - platforms: linux/amd64,linux/arm64 - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository_owner }}/awsbck - flavor: | - latest=true - tags: | - type=raw,value=${{steps.semver.outputs.major}},enable=${{ steps.semver.outputs.major != '0' }} - type=raw,value=${{steps.semver.outputs.major}}.${{steps.semver.outputs.minor}} - type=raw,value=${{steps.semver.outputs.version}} - - name: Build and push - uses: docker/build-push-action@v6 - with: - push: true - context: . - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64,linux/arm64