From b4b0e076010c4dda31850d3d97c3784f0d866141 Mon Sep 17 00:00:00 2001 From: utam0k Date: Mon, 23 Nov 2026 17:21:13 +0900 Subject: [PATCH] automate the release after the environment approval Signed-off-by: utam0k --- .github/release.yml | 6 +-- .github/workflows/release.yaml | 53 +++++++++++++++----- .github/workflows/update_version_config.yaml | 44 ---------------- .tagpr | 3 +- 4 files changed, 45 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/update_version_config.yaml diff --git a/.github/release.yml b/.github/release.yml index 56906eb55b..77883243e7 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -3,12 +3,12 @@ changelog: authors: - dependabot categories: - - title: 💪 Improvements - labels: - - kind/feature - title: 💥 Breaking Changes labels: - breaking change + - title: 💪 Improvements + labels: + - kind/feature - title: 🐛 Bug Fixes labels: - kind/bug diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2c2a16c15e..f9df901a42 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,6 +5,10 @@ on: tags: ["v[0-9]+.[0-9]+.[0-9]+*"] workflow_dispatch: +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + jobs: parse: runs-on: ubuntu-latest @@ -84,29 +88,52 @@ jobs: - name: Create release draft shell: bash run: | - set -x - gh release create "${{ github.ref }}" --generate-notes --draft - gh release upload "${{ github.ref }}" artifacts/*/* + set -euxo pipefail + state=$(gh release view "$TAG" --json isDraft --jq 'if .isDraft then "draft" else "published" end' || echo absent) + case "$state" in + published) + echo "$TAG is already published" + exit 0 + ;; + absent) + gh release create "$TAG" --verify-tag --generate-notes --draft + ;; + esac + gh release upload "$TAG" artifacts/*/* --clobber env: GH_TOKEN: ${{ github.token }} - RELEASE_NAME: "${{ needs.parse.outputs.version }} Release" + TAG: ${{ github.ref_name }} publish: name: Publish Packages - needs: release + needs: + - parse + - release runs-on: ubuntu-24.04 if: ${{ github.repository == 'youki-dev/youki' }} + permissions: + contents: write env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + VERSION: ${{ needs.parse.outputs.version }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain and cache uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Publish libcgroups - run: cargo publish -p libcgroups --no-verify - - name: Publish libcontainer - run: cargo publish -p libcontainer --no-verify - - name: Publish liboci-cli - run: cargo publish -p liboci-cli --no-verify - - name: Publish youki - run: cargo publish -p youki --no-verify + - name: Publish crates + shell: bash + run: | + set -euo pipefail + for crate in libcgroups libcontainer liboci-cli youki; do + index="https://index.crates.io/${crate:0:2}/${crate:2:2}/${crate}" + if curl -fsSL "$index" | jq -e --arg v "$VERSION" 'select(.vers == $v)' > /dev/null; then + echo "$crate $VERSION is already on crates.io" + else + cargo publish -p "$crate" --no-verify + fi + done + - name: Publish the GitHub release + run: gh release edit "$TAG" --draft=false + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} diff --git a/.github/workflows/update_version_config.yaml b/.github/workflows/update_version_config.yaml deleted file mode 100644 index 189121fe11..0000000000 --- a/.github/workflows/update_version_config.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: 🤖 Automated Update tagpr config - -on: - workflow_dispatch: - inputs: - version: - description: 'Version to release' - required: true -jobs: - config: - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Update tagpr config - run: | - cat << EOF > .tagpr - [tagpr] - vPrefix = true - releaseBranch = main - versionFile = justfile - command = just version-up ${{ github.event.inputs.version }} - release = false - changelog = true - EOF - - uses: peter-evans/create-pull-request@v5 - with: - title: 'config: Automated Tagpr Update for ${{ github.event.inputs.version }}' - add-paths: | - .tagpr - body: | - - Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action - commit-message: | - 🤖 update tagpr config using robot. - branch: tagpr-${{ github.event.inputs.version }} - base: main - signoff: true - delete-branch: true - token: ${{ secrets.GITHUB_TOKEN }} - committer: github-actions[bot] - author: github-actions[bot] diff --git a/.tagpr b/.tagpr index 6f59ce91c1..5f0b0266e9 100644 --- a/.tagpr +++ b/.tagpr @@ -2,6 +2,7 @@ vPrefix = true releaseBranch = main versionFile = - - command = just version-up 0.7.1 + command = "just version-up ${TAGPR_NEXT_VERSION#v}" + minorLabels = breaking change release = false changelog = true