From f281f029f053bc1464d8398dd17ba3ccdd243621 Mon Sep 17 00:00:00 2001 From: David Bernard Date: Thu, 12 Dec 2024 17:58:41 +0100 Subject: [PATCH] ci: build & push container after the release --- .github/workflows/ci.yml | 2 +- .github/workflows/release-after.yml | 43 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 9 ++++++ Cargo.toml | 1 + dist-workspace.toml | 15 +++++----- 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release-after.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4df09ac..d77336c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - uses: jdx/mise-action@v2 - run: mise install shell: bash - - run: mise run ci + - run: mise run --jobs 1 ci shell: bash - run: ${SCCACHE_PATH} --show-stats shell: bash diff --git a/.github/workflows/release-after.yml b/.github/workflows/release-after.yml new file mode 100644 index 0000000..78397d3 --- /dev/null +++ b/.github/workflows/release-after.yml @@ -0,0 +1,43 @@ +name: release-after + +on: + workflow_call: + inputs: + plan: + required: true + type: string + workflow_dispatch: + inputs: + plan: + description: plan json (eg {"releases":[{"app_version":"0.2.1"}]}) to extract version + required: true + type: string + +jobs: + container-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - id: version + shell: bash + run: | + cat >plan.json << EOF + {{ inputs.plan }} + EOF + VERSION=$(yq -r '.releases[0].app_version' < plan.json) + echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v6 + with: + push: true + build-args: VERSION=${{ steps.version.outputs.VERSION }} + platforms: linux/amd64,linux/arm64 + target: cdviz-collector + tags: ghcr.io/cdviz-dev/cdviz-collector:${{ steps.version.outputs.VERSION }} + # cache-from: type=gha + # cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6a79f4..749ed29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -327,3 +327,12 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + + custom-release-after: + needs: + - plan + - announce + uses: ./.github/workflows/release-after.yml + with: + plan: ${{ needs.plan.outputs.val }} + secrets: inherit diff --git a/Cargo.toml b/Cargo.toml index a80a362..3cd14cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" version = "0.2.1" authors = ["David Bernard"] license = "Apache-2.0" +homepage = "https://cdviz.dev" repository = "https://github.com/cdviz-dev/cdviz-collector" rust-version = "1.83.0" publish = true diff --git a/dist-workspace.toml b/dist-workspace.toml index 43a447a..46f25d6 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -12,16 +12,17 @@ installers = ["shell", "homebrew"] # A GitHub repo to push Homebrew formulas to tap = "cdviz-dev/homebrew-tap" # Target platforms to build apps for (Rust target-triple syntax) -targets = [ - "aarch64-apple-darwin", - "x86_64-apple-darwin", - "aarch64-unknown-linux-musl", - "x86_64-unknown-linux-musl", - "x86_64-pc-windows-msvc", -] +targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-musl", "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" # Publish jobs to run in CI publish-jobs = ["homebrew"] # Whether to install an updater program install-updater = false +# Post-announce jobs to run in CI +post-announce-jobs = ["./release-after"] + +# [dist.github-custom-runners] +# buildjet could be used to build the binaries (faster, cheaper? than github's runners) +# aarch64-unknown-linux-gnu = "buildjet-8vcpu-ubuntu-2204-arm" +# aarch64-unknown-linux-musl = "buildjet-8vcpu-ubuntu-2204-arm"