From e44f45714d34ec168a2a445667b25e37eaecaa1e Mon Sep 17 00:00:00 2001 From: Ethan Konkolowicz Date: Fri, 30 Jan 2026 15:52:25 -0500 Subject: [PATCH] removed auto versioning and changelog gen from workflow --- .github/workflows/version-and-publish.yml | 138 ++++------------------ 1 file changed, 22 insertions(+), 116 deletions(-) diff --git a/.github/workflows/version-and-publish.yml b/.github/workflows/version-and-publish.yml index 7080c0e..c8f1b90 100644 --- a/.github/workflows/version-and-publish.yml +++ b/.github/workflows/version-and-publish.yml @@ -1,10 +1,10 @@ -name: Version Packages Create Release Branch and Publish +name: Validate and Publish on: - workflow_dispatch: # allows manual invocation - push: - tags: - - "v*.*.*" # triggers on tags like v1.0.0 + pull_request: + types: [closed] + branches: + - main permissions: contents: write @@ -12,14 +12,25 @@ permissions: jobs: build: + if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v') runs-on: ubuntu-latest + outputs: + version: ${{ steps.extract-version.outputs.version }} steps: # https://github.com/actions/checkout - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 # required for git tags and history - ref: ${{ github.event.repository.default_branch }} + + - name: Extract and validate version from branch name + id: extract-version + run: | + VERSION="${GITHUB_HEAD_REF#release/}" + if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "::error::Branch name does not match expected format release/vX.X.X (got: $GITHUB_HEAD_REF)" + exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Extracted version: $VERSION" # https://github.com/ruby/setup-ruby - name: Set up Ruby @@ -29,18 +40,6 @@ jobs: bundler-cache: true working-directory: turnkey_client - # Check if there are pending changesets - - name: Check for pending releases - run: | - echo "Checking for pending changesets..." - git fetch origin main - CHANGESET_COUNT=$(find .changesets -maxdepth 1 -name '*.md' ! -name '_*' 2>/dev/null | wc -l) - if [ "$CHANGESET_COUNT" -eq 0 ]; then - echo "No unreleased changesets found, exiting" - exit 1 - fi - echo "Found $CHANGESET_COUNT pending changeset(s), continuing" - - name: Run rubocop run: | gem install rubocop @@ -50,97 +49,19 @@ jobs: working-directory: turnkey_client run: gem build turnkey_client.gemspec - version-and-rebuild: - runs-on: ubuntu-latest - needs: build - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 # required for git tags and history - ref: ${{ github.event.repository.default_branch }} - - - name: Set up Ruby - uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0 - with: - ruby-version: '3.3' - bundler-cache: true - working-directory: turnkey_client - - - name: Configure Git User - run: | - git config user.name "tkhq-deploy" - git config user.email "github@turnkey.engineering" - - - name: Create and switch to release branch - run: | - git fetch origin - git checkout -B release/${{ github.ref_name }} origin/release/${{ github.ref_name }} || \ - git checkout -B release/${{ github.ref_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Process changesets, bump version, and generate changelog - - name: Version and prepare release - run: | - rm -f .changesets/_current_release.json - make prepare-release - - - name: Validate gem builds with updated version - working-directory: turnkey_client - run: | - gem build turnkey_client.gemspec - rm -f *.gem - - - name: Debug Git Status - run: | - echo "Git status before commit:" - git status --short - echo "Listing .changesets directory:" - ls -la .changesets || echo ".changesets directory not found" - - - name: Commit versioned changes - run: | - git add -A - git commit -m "chore: release turnkey_client" || echo "No changes to commit" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Push changes to release branch - run: | - git push -u origin release/${{ github.ref_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload release artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: release-artifacts-${{ github.ref_name }} - path: | - turnkey_client/** - !turnkey_client/vendor - !turnkey_client/*.gem - turnkey_client_inputs/config.json - .changesets/** - CHANGELOG.md - retention-days: 7 - prepare-release: runs-on: ubuntu-latest - needs: version-and-rebuild + needs: build steps: # https://github.com/actions/checkout - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 # required for git tags and history - ref: release/${{ github.ref_name }} - name: Create GitHub Release uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2 with: - tag_name: ${{ github.ref_name }} - name: Release ${{ github.ref_name }} + tag_name: ${{ needs.build.outputs.version }} + name: Release ${{ needs.build.outputs.version }} generate_release_notes: true draft: true prerelease: false @@ -159,14 +80,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 # required for git tags and history - ref: release/${{ github.ref_name }} - - - name: Configure Git User - run: | - git config user.name "tkhq-deploy" - git config user.email "github@turnkey.engineering" - name: Set up Ruby uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0 @@ -175,13 +88,6 @@ jobs: bundler-cache: true working-directory: turnkey_client - # Download the release artifacts generated by version-and-rebuild - - name: Download release artifacts - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 - with: - name: release-artifacts-${{ github.ref_name }} - path: . - # OIDC trusted publishing # Uses the same credentials action as rubygems/release-gem - name: Configure trusted publishing credentials