From 7cc2bedfdeee8b860e518e286489cf8e1c8ba752 Mon Sep 17 00:00:00 2001 From: Taaha Rauf Date: Fri, 20 Feb 2026 15:27:33 -0600 Subject: [PATCH] ci: automate releases with release-please (#478) --- .github/workflows/release_please.yaml | 40 +++++++++++++++++ .release-please-manifest.json | 3 ++ package.json | 2 +- release-please-config.json | 26 +++++++++++ tool/release_ready.sh | 64 --------------------------- tool/retag_v3.sh | 21 --------- 6 files changed, 70 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/release_please.yaml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json delete mode 100755 tool/release_ready.sh delete mode 100755 tool/retag_v3.sh diff --git a/.github/workflows/release_please.yaml b/.github/workflows/release_please.yaml new file mode 100644 index 00000000..71dd5044 --- /dev/null +++ b/.github/workflows/release_please.yaml @@ -0,0 +1,40 @@ +name: release_please + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + create_release_pr: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + manifest-file: ".release-please-manifest.json" + config-file: "release-please-config.json" + + retag: + needs: create_release_pr + if: ${{ needs.create_release_pr.outputs.release_created == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Update major version tag + run: | + VERSION=${{ needs.create_release_pr.outputs.tag_name }} + MAJOR=${VERSION%%.*} + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + git tag -fa "${MAJOR}" -m "Update ${MAJOR} tag to ${VERSION}" + git push origin "${MAJOR}" --force diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..d4f6f299 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "3.0.0" +} diff --git a/package.json b/package.json index 4c96db31..3d491dca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "very-good-coverage", - "version": "2.1.0", + "version": "3.0.0", "description": "A Github Action which helps enforce code coverage threshold using lcov", "type": "module", "main": "index.js", diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..e044f5e8 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "changelog-sections": [ + { "type": "feat", "section": "Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "refactor", "section": "Refactors" }, + { "type": "chore", "section": "Miscellaneous Chores" }, + { "type": "docs", "section": "Docs" } + ], + "pull-request-header": ":rotating_light: There are changes ready for release :rocket:\n\nℹ Merge this PR once the team confirms the release is ready.\n", + "pull-request-title-pattern": "chore: ${version}", + "include-component-in-tag": false, + "packages": { + ".": { + "release-type": "node", + "changelog-path": "CHANGELOG.md" + } + }, + "exclude-paths": [ + ".github", + ".release-please-manifest.json", + "release-please-config.json", + "CONTRIBUTING.md", + "tool" + ] +} diff --git a/tool/release_ready.sh b/tool/release_ready.sh deleted file mode 100755 index 3eb4d351..00000000 --- a/tool/release_ready.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# Ensures that the package is ready for a release. -# -# Will update the version.dart file and update the CHANGELOG.md. -# -# Set it up for a new version: -# `./release_ready.sh - -currentBranch=$(git symbolic-ref --short -q HEAD) -if [[ ! $currentBranch == "main" ]]; then - echo "Releasing is only supported on the main branch." - exit 1 -fi - -# Get information -old_version=$(git for-each-ref --count=2 --format "%(refname:short)" --sort=-creatordate refs/tags | tail -n +2 | cut -c 2-) - -if [ -z "$old_version" ]; then - echo "Current version was not resolved." - exit 1 -fi - -# Get new version -new_version="$1"; - -if [[ "$new_version" == "" ]]; then - echo "No new version supplied, please provide one" - exit 1 -fi - -if [[ "$new_version" == "$old_version" ]]; then - echo "Current version is $old_version, can't update." - exit 1 -fi - -# Retrieving all the commits in the current directory since the last tag. -previousTag="v${old_version}" -raw_commits="$(git log --pretty=format:"%s" --no-merges --reverse $previousTag..HEAD -- .)" -markdown_commits=$(echo "$raw_commits" | sed -En "s/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/VeryGoodOpenSource\/very_good_coverage\/pull\/\1))/p") - -if [[ "$markdown_commits" == "" ]]; then - echo "No commits since last tag, can't update." - exit 0 -fi -commits=$(echo "$markdown_commits" | sed -En "s/^/- /p") - -if grep -q v$new_version "CHANGELOG.md"; then - echo "CHANGELOG already contains version $new_version." - exit 1 -fi - -# Add a new version entry with the found commits to the CHANGELOG.md. -echo "# ${new_version} \n\n ${commits}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md -echo "CHANGELOG generated, validate entries here: $(pwd)/CHANGELOG.md" - -echo "Creating git branch for ver_good_cli@$new_version" -git checkout -b "chore/$new_version" > /dev/null - -git add pubspec.yaml CHANGELOG.md - -echo "" -echo "Run the following command if you wish to commit the changes:" -echo "git commit -m \"chore: v$new_version\"" \ No newline at end of file diff --git a/tool/retag_v3.sh b/tool/retag_v3.sh deleted file mode 100755 index 17565062..00000000 --- a/tool/retag_v3.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Updates the "v3" tag to point to a newer release. -# To be executed whenever a new 1.x tag is created. -# Usage: ./retag_v3.sh - -currentBranch=$(git symbolic-ref --short -q HEAD) -if [[ ! $currentBranch == "main" ]]; then - echo "Re-tagging is only supported on the main branch." - exit 1 -fi - -# Get new version -new_version="$1"; - -if [[ "$new_version" == "" ]]; then - echo "No new version supplied, please provide one" - exit 1 -fi - -git tag -d v3 && git tag v3 v$new_version && git push origin --delete v3 && git push origin v3 \ No newline at end of file