From d347071dde9029db7214a09ec6677b9d2ff07377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hikari=20=28=E3=81=B2=E3=81=8B=E3=82=8A=29?= Date: Sat, 27 Jan 2024 15:58:19 -0600 Subject: [PATCH] feat: add release workflows (#22) --- .github/CODEOWNERS | 2 +- .github/workflows/post-release.yml | 57 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 55 +++++++++++++++++++--------- justfile | 38 ++++++++++++++++++++ 4 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/post-release.yml create mode 100644 justfile diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5c13cc7..a38f054 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @gmpinder +* @gmpinder @akarui-hikarii diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml new file mode 100644 index 0000000..a4fe743 --- /dev/null +++ b/.github/workflows/post-release.yml @@ -0,0 +1,57 @@ +name: Post-release version bump + +# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow +on: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + ci: + if: github.repository == 'blue-build/cli' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install cargo-release + run: cargo install cargo-release + + - name: Git setup + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Setup post-release version bump + run: | + # Read the current version from Cargo.toml + current_version=$(cargo metadata --format-version 1 --no-deps | \ + jq --raw-output '.packages | .[] | select(.name == "blue-build").version') + + # Sanity check: current version should be 0.X.Y + if ! grep -q '^0\.[0-9]\+\.[0-9]\+$' <<< "${current_version}"; then + echo "Invalid version (not in 0.X.Y format): ${current_version}" + exit 1 + fi + + minor_version=$(sed 's/^0\.\([0-9]\+\).*/\1/' <<< "${current_version}") + next_version=0.$((minor_version + 1)).0-dev + echo "Bumping version to ${next_version}" + + # See release.yml for meaning of these arguments + cargo release "${next_version}" \ + --workspace \ + --no-publish \ + --no-tag \ + --no-confirm \ + --no-push + + - name: Create PR + uses: peter-evans/create-pull-request@v5 + with: + delete-branch: true + base: "main" + title: "Bump Version after Release" + body: | + Bump version after release + This PR has been auto-generated \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 025784a..b86a0b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ env: jobs: release: + if: github.repository == 'blue-build/cli' runs-on: ubuntu-latest permissions: id-token: write @@ -18,10 +19,9 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Git setup - run: | - git config user.name github-actions - git config user.email github-actions@github.com + + - uses: chainguard-dev/actions/setup-gitsign@main + - uses: actions/cache@v4 with: path: | @@ -32,17 +32,40 @@ jobs: ~/.cargo/registry/cache/ key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }} - - uses: chainguard-dev/actions/setup-gitsign@main - - # Pulling rust toolchain & install linux dependencies - - uses: dtolnay/rust-toolchain@stable - - name: Install cargo-release - uses: taiki-e/install-action@v1 - with: - tool: cargo-smart-release + run: cargo install cargo-release - - name: Release - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - run: cargo smart-release -ue + - name: Git setup + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + # Leaving bevy comments here for us to discuss. Do we want to start tagging our pre-releases with `dev`? + - name: Setup release + run: | + # release: remove the dev suffix, like going from 0.X.0-dev to 0.X.0 + # --workspace: updating all crates in the workspace + # --no-publish: do not publish to crates.io + # --execute: not a dry run + # --no-tag: do not push tag for each new version + # --no-push: do not push the update commits + # --dependent-version upgrade: change 0.X.0-dev in internal dependencies to 0.X.0 + # --exclude: ignore those packages + cargo release release \ + --workspace \ + --no-publish \ + --execute \ + --no-tag \ + --no-confirm \ + --no-push \ + --dependent-version upgrade + + - name: Create PR + uses: peter-evans/create-pull-request@v5 + with: + delete-branch: true + base: "main" + title: "Preparing Next Release" + body: | + Preparing next release + This PR has been auto-generated diff --git a/justfile b/justfile new file mode 100644 index 0000000..39418eb --- /dev/null +++ b/justfile @@ -0,0 +1,38 @@ +#!/usr/bin/env just --justfile + +export RUST_BACKTRACE := "1" + +set shell := ["bash", "-cu"] +set dotenv-load := true + +# default recipe to display help information +default: + @just --list + +cargo_bump_release_test: + #!/usr/bin/env bash + set -euxo pipefail + + # Read the current version from Cargo.toml + current_version=$(cargo metadata --format-version 1 --no-deps | \ + jq --raw-output '.packages | .[] | select(.name == "blue-build").version') + + echo "Current Version: $current_version" + + # Sanity check: current version should be 0.X.Y + if ! grep -q '^0\.[0-9]\+\.[0-9]\+$' <<< "${current_version}"; then + echo "Invalid version (not in 0.X.Y format): ${current_version}" + exit 1 + fi + + minor_version=$(sed 's/^0\.\([0-9]\+\).*/\1/' <<< "${current_version}") + next_version=0.$((minor_version + 1)).0-dev + echo "Bumping version to ${next_version}" + + # See release.yml for meaning of these arguments + cargo release "${next_version}" \ + --workspace \ + --no-publish \ + --no-tag \ + --no-confirm \ + --no-push \ No newline at end of file