1- name : Version Packages Create Release Branch and Publish
1+ name : Validate and Publish
22
33on :
4- workflow_dispatch : # allows manual invocation
5- push :
6- tags :
7- - " v*.*.* " # triggers on tags like v1.0.0
4+ pull_request :
5+ types : [closed]
6+ branches :
7+ - main
88
99permissions :
1010 contents : write
1111 id-token : write # required for RubyGems trusted publishing (OIDC)
1212
1313jobs :
1414 build :
15+ if : github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v')
1516 runs-on : ubuntu-latest
17+ outputs :
18+ version : ${{ steps.extract-version.outputs.version }}
1619 steps :
1720 # https://github.com/actions/checkout
1821 - name : Checkout
1922 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20- with :
21- fetch-depth : 0 # required for git tags and history
22- ref : ${{ github.event.repository.default_branch }}
23+
24+ - name : Extract version from branch name
25+ id : extract-version
26+ run : |
27+ VERSION="${GITHUB_HEAD_REF#release/}"
28+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29+ echo "Extracted version: $VERSION"
2330
2431 # https://github.com/ruby/setup-ruby
2532 - name : Set up Ruby
2936 bundler-cache : true
3037 working-directory : turnkey_client
3138
32- # Check if there are pending changesets
33- - name : Check for pending releases
34- run : |
35- echo "Checking for pending changesets..."
36- git fetch origin main
37- CHANGESET_COUNT=$(find .changesets -maxdepth 1 -name '*.md' ! -name '_*' 2>/dev/null | wc -l)
38- if [ "$CHANGESET_COUNT" -eq 0 ]; then
39- echo "No unreleased changesets found, exiting"
40- exit 1
41- fi
42- echo "Found $CHANGESET_COUNT pending changeset(s), continuing"
43-
4439 - name : Run rubocop
4540 run : |
4641 gem install rubocop
@@ -50,97 +45,19 @@ jobs:
5045 working-directory : turnkey_client
5146 run : gem build turnkey_client.gemspec
5247
53- version-and-rebuild :
54- runs-on : ubuntu-latest
55- needs : build
56- steps :
57- - name : Checkout
58- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
59- with :
60- fetch-depth : 0 # required for git tags and history
61- ref : ${{ github.event.repository.default_branch }}
62-
63- - name : Set up Ruby
64- uses : ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0
65- with :
66- ruby-version : ' 3.3'
67- bundler-cache : true
68- working-directory : turnkey_client
69-
70- - name : Configure Git User
71- run : |
72- git config user.name "tkhq-deploy"
73- git config user.email "github@turnkey.engineering"
74-
75- - name : Create and switch to release branch
76- run : |
77- git fetch origin
78- git checkout -B release/${{ github.ref_name }} origin/release/${{ github.ref_name }} || \
79- git checkout -B release/${{ github.ref_name }}
80- env :
81- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82-
83- # Process changesets, bump version, and generate changelog
84- - name : Version and prepare release
85- run : |
86- rm -f .changesets/_current_release.json
87- make prepare-release
88-
89- - name : Validate gem builds with updated version
90- working-directory : turnkey_client
91- run : |
92- gem build turnkey_client.gemspec
93- rm -f *.gem
94-
95- - name : Debug Git Status
96- run : |
97- echo "Git status before commit:"
98- git status --short
99- echo "Listing .changesets directory:"
100- ls -la .changesets || echo ".changesets directory not found"
101-
102- - name : Commit versioned changes
103- run : |
104- git add -A
105- git commit -m "chore: release turnkey_client" || echo "No changes to commit"
106- env :
107- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108-
109- - name : Push changes to release branch
110- run : |
111- git push -u origin release/${{ github.ref_name }}
112- env :
113- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
114-
115- - name : Upload release artifacts
116- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
117- with :
118- name : release-artifacts-${{ github.ref_name }}
119- path : |
120- turnkey_client/**
121- !turnkey_client/vendor
122- !turnkey_client/*.gem
123- turnkey_client_inputs/config.json
124- .changesets/**
125- CHANGELOG.md
126- retention-days : 7
127-
12848 prepare-release :
12949 runs-on : ubuntu-latest
130- needs : version-and-rebuild
50+ needs : build
13151 steps :
13252 # https://github.com/actions/checkout
13353 - name : Checkout
13454 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
135- with :
136- fetch-depth : 0 # required for git tags and history
137- ref : release/${{ github.ref_name }}
13855
13956 - name : Create GitHub Release
14057 uses : softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
14158 with :
142- tag_name : ${{ github.ref_name }}
143- name : Release ${{ github.ref_name }}
59+ tag_name : ${{ needs.build.outputs.version }}
60+ name : Release ${{ needs.build.outputs.version }}
14461 generate_release_notes : true
14562 draft : true
14663 prerelease : false
@@ -159,14 +76,6 @@ jobs:
15976 steps :
16077 - name : Checkout
16178 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
162- with :
163- fetch-depth : 0 # required for git tags and history
164- ref : release/${{ github.ref_name }}
165-
166- - name : Configure Git User
167- run : |
168- git config user.name "tkhq-deploy"
169- git config user.email "github@turnkey.engineering"
17079
17180 - name : Set up Ruby
17281 uses : ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0
@@ -175,13 +84,6 @@ jobs:
17584 bundler-cache : true
17685 working-directory : turnkey_client
17786
178- # Download the release artifacts generated by version-and-rebuild
179- - name : Download release artifacts
180- uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
181- with :
182- name : release-artifacts-${{ github.ref_name }}
183- path : .
184-
18587 # OIDC trusted publishing
18688 # Uses the same credentials action as rubygems/release-gem
18789 - name : Configure trusted publishing credentials
0 commit comments