From b5010dd6df1899f22b681638ec5388077897459f Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Sat, 7 Feb 2026 17:08:51 -0500 Subject: [PATCH] Add release-please for automated releases Replace the manual version-bump workflow and PR-triggered release flow with release-please for automated changelog generation and releases. The publish workflow now triggers on GitHub release events. Also adds a PR title linter to enforce conventional commits. --- .github/workflows/lint-pr-title.yml | 20 +++++++ .github/workflows/release-please.yml | 25 +++++++++ .github/workflows/release.yml | 44 ++------------- .github/workflows/version-bump.yml | 80 ---------------------------- .release-please-manifest.json | 3 ++ release-please-config.json | 11 ++++ 6 files changed, 63 insertions(+), 120 deletions(-) create mode 100644 .github/workflows/lint-pr-title.yml create mode 100644 .github/workflows/release-please.yml delete mode 100644 .github/workflows/version-bump.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 00000000..83867c43 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,20 @@ +name: Lint PR Title + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: + pull-requests: read + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..d8efdc7f --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,25 @@ +name: Release Please + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate-token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ vars.SDK_BOT_APP_ID }} + private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }} + + - uses: googleapis/release-please-action@v4 + with: + token: ${{ steps.generate-token.outputs.token }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a1b4a97..d054fb12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,53 +1,16 @@ name: Release on: - pull_request: - types: [closed] - branches: [main] + release: + types: [published] defaults: run: shell: bash jobs: - create-release: - name: Create GitHub Release - if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump') - runs-on: ubuntu-latest - permissions: - contents: write - outputs: - version: ${{ steps.get-version.outputs.version }} - steps: - - name: Generate token - id: generate-token - uses: actions/create-github-app-token@v2 - with: - app-id: ${{ vars.SDK_BOT_APP_ID }} - private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }} - - - name: Checkout - uses: actions/checkout@v6 - with: - token: ${{ steps.generate-token.outputs.token }} - - - name: Get version from version.rb - id: get-version - run: | - VERSION=$(grep "VERSION = " lib/workos/version.rb | sed "s/.*VERSION = '\(.*\)'/\1/") - echo "version=$VERSION" >> $GITHUB_OUTPUT - - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - tag_name: v${{ steps.get-version.outputs.version }} - name: v${{ steps.get-version.outputs.version }} - generate_release_notes: true - token: ${{ steps.generate-token.outputs.token }} - publish: name: Publish to RubyGems - needs: create-release runs-on: ubuntu-latest permissions: id-token: write @@ -72,5 +35,6 @@ jobs: - name: Publish to RubyGems run: | + VERSION="${GITHUB_REF_NAME#v}" bundle exec rake build - gem push pkg/workos-${{ needs.create-release.outputs.version }}.gem --host https://rubygems.org + gem push pkg/workos-${VERSION}.gem --host https://rubygems.org diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml deleted file mode 100644 index 332800c6..00000000 --- a/.github/workflows/version-bump.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Version Bump - -on: - workflow_dispatch: - inputs: - bump_type: - description: "Version bump type" - required: true - type: choice - options: - - patch - - minor - - major - -jobs: - bump-version: - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - - name: Generate token - id: generate-token - uses: actions/create-github-app-token@v2 - with: - app-id: ${{ vars.SDK_BOT_APP_ID }} - private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }} - - - name: Checkout - uses: actions/checkout@v6 - with: - token: ${{ steps.generate-token.outputs.token }} - - - name: Configure Git - run: | - git config user.name "workos-bot[bot]" - git config user.email "workos-bot[bot]@users.noreply.github.com" - - - name: Read current version - id: current-version - run: | - CURRENT_VERSION=$(grep "VERSION = " lib/workos/version.rb | sed "s/.*VERSION = '\(.*\)'/\1/") - echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - - - name: Bump version - id: bump-version - run: | - CURRENT_VERSION="${{ steps.current-version.outputs.version }}" - IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" - - case "${{ github.event.inputs.bump_type }}" in - major) - NEW_VERSION="$((MAJOR + 1)).0.0" - ;; - minor) - NEW_VERSION="$MAJOR.$((MINOR + 1)).0" - ;; - patch) - NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" - ;; - esac - - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT - - - name: Update version in version.rb - run: | - sed -i "s/VERSION = '.*'/VERSION = '${{ steps.bump-version.outputs.new_version }}'/" lib/workos/version.rb - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v8 - with: - token: ${{ steps.generate-token.outputs.token }} - commit-message: "v${{ steps.bump-version.outputs.new_version }}" - title: "v${{ steps.bump-version.outputs.new_version }}" - body: | - Bumps version from ${{ steps.current-version.outputs.version }} to ${{ steps.bump-version.outputs.new_version }}. - - This PR was automatically created by the version-bump workflow. - branch: version-bump-${{ steps.bump-version.outputs.new_version }} - labels: version-bump diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..a3a12f49 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "6.0.0" +} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..1a8d77de --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "ruby", + "package-name": "workos", + "version-file": "lib/workos/version.rb", + "changelog-path": "CHANGELOG.md" + } + } +}