Skip to content

Commit f39a2da

Browse files
GLinnik21DariaKunoichi
authored andcommitted
Update release workflow: Remove test functionality and add publish_only option (kstenerud#629)
* Update release workflow: remove test functionality and add skip_tag option * Update release workflow: rename parameter to publish_only and clarify descriptions * Fix workflow conditions to properly handle all parameter combinations * Use macOS-15 runner and upgrade checkout to v4
1 parent b9909cf commit f39a2da

File tree

1 file changed

+22
-48
lines changed

1 file changed

+22
-48
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version to release'
7+
description: "Version number for this release"
88
required: true
99
dry_run:
10-
description: 'Run in dry-run mode (do not push to CocoaPods)'
10+
description: "Test workflow without publishing to CocoaPods"
1111
type: boolean
1212
default: false
1313
required: false
14-
test_fail:
15-
description: 'Intentionally fail at a specific stage (for testing)'
16-
type: string
17-
default: 'none'
14+
publish_only:
15+
description: "Publish to CocoaPods without version updates or tagging"
16+
type: boolean
17+
default: false
1818
required: false
1919

2020
jobs:
2121
release:
22-
runs-on: macos-latest
22+
runs-on: macos-15
2323
outputs:
2424
commit_sha: ${{ steps.save_commit_info.outputs.commit_sha }}
2525
version: ${{ github.event.inputs.version }}
2626
dry_run: ${{ github.event.inputs.dry_run }}
2727
tag_name: ${{ steps.create_tag.outputs.tag_name }}
2828
steps:
2929
- name: Checkout code
30-
uses: actions/checkout@v2
30+
uses: actions/checkout@v4
3131

3232
- name: Set up Ruby
3333
uses: ruby/setup-ruby@v1
3434
with:
35-
ruby-version: '3.2.2'
35+
ruby-version: "3.2.2"
3636

3737
- name: Install Ruby Gems
3838
run: sudo bundle install
@@ -52,12 +52,6 @@ jobs:
5252
xcodebuild -runFirstLaunch
5353
done
5454
55-
- name: Test failure - Early stage
56-
if: ${{ github.event.inputs.test_fail == 'early' }}
57-
run: |
58-
echo "Intentionally failing at early stage for testing"
59-
exit 1
60-
6155
- name: Update version in podspec
6256
run: sed -i '' 's/s.version = "[^"]*"/s.version = "${{ github.event.inputs.version }}"/' KSCrash.podspec
6357

@@ -71,7 +65,7 @@ jobs:
7165
run: |
7266
# Update SPM version
7367
sed -i '' "s/\.package(url: \"https:\/\/github.com\/kstenerud\/KSCrash.git\", .upToNextMajor(from: \"[^\"]*\"))/\.package(url: \"https:\/\/github.com\/kstenerud\/KSCrash.git\", .upToNextMajor(from: \"${{ github.event.inputs.version }}\"))/" README.md
74-
68+
7569
# Update CocoaPods version
7670
VERSION="${{ github.event.inputs.version }}"
7771
if [[ "$VERSION" == *"-"* ]]; then
@@ -81,70 +75,50 @@ jobs:
8175
# It's a release version, use major.minor
8276
sed -i '' "s/pod 'KSCrash'.*$/pod 'KSCrash', '~> ${VERSION%.*}'/" README.md
8377
fi
84-
78+
8579
echo "README.md updated with version ${{ github.event.inputs.version }}"
8680
8781
- name: Commit version update
8882
id: commit_version
83+
if: ${{ github.event.inputs.publish_only != 'true' }}
8984
run: |
9085
git config --global user.name 'github-actions[bot]'
9186
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
9287
git add .
9388
git commit -m "Update version to ${{ github.event.inputs.version }}"
9489
git push
95-
90+
9691
- name: Save commit information
9792
id: save_commit_info
93+
if: ${{ github.event.inputs.publish_only != 'true' }}
9894
run: |
9995
COMMIT_SHA=$(git rev-parse HEAD)
10096
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
101-
102-
- name: Test failure - After commit
103-
if: ${{ github.event.inputs.test_fail == 'mid' }}
104-
run: |
105-
echo "Intentionally failing after commit but before tag for testing"
106-
exit 1
10797
10898
- name: Create git tag
10999
id: create_tag
100+
if: ${{ github.event.inputs.publish_only != 'true' }}
110101
run: |
111102
if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then
112103
TAG_NAME="${{ github.event.inputs.version }}-dryrun"
113104
else
114105
TAG_NAME="${{ github.event.inputs.version }}"
115106
fi
116-
107+
117108
git tag $TAG_NAME
118109
git push origin $TAG_NAME
119110
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
120-
121-
- name: Test failure - After tag
122-
if: ${{ github.event.inputs.test_fail == 'late' }}
123-
run: |
124-
echo "Intentionally failing after tag but before publishing for testing"
125-
exit 1
126111
127112
- name: Publish to CocoaPods
128-
if: ${{ !github.event.inputs.dry_run && github.event.inputs.test_fail != 'any' }}
113+
if: ${{ github.event.inputs.dry_run != 'true' }}
129114
env:
130115
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_PASSWORD }}
131116
run: pod trunk push KSCrash.podspec --verbose
132-
133-
- name: Skip publishing
134-
if: ${{ github.event.inputs.dry_run || github.event.inputs.test_fail != 'none' }}
135-
run: |
136-
echo "Publishing skipped - running in test or dry-run mode"
137-
138-
- name: Test failure - During publishing
139-
if: ${{ github.event.inputs.test_fail == 'publish' }}
140-
run: |
141-
echo "Intentionally failing during publishing stage for testing"
142-
exit 1
143117

144118
rollback:
145119
runs-on: macos-15
146120
needs: release
147-
if: failure()
121+
if: failure() && github.event.inputs.publish_only != 'true'
148122
steps:
149123
- name: Checkout code
150124
uses: actions/checkout@v2
@@ -165,7 +139,7 @@ jobs:
165139
else
166140
TAG_TO_DELETE="${{ needs.release.outputs.version }}"
167141
fi
168-
142+
169143
git tag -d $TAG_TO_DELETE || echo "Tag not found locally"
170144
echo "TAG_TO_DELETE=$TAG_TO_DELETE" >> $GITHUB_ENV
171145
@@ -188,7 +162,7 @@ jobs:
188162
# Fallback: search by commit message
189163
SEARCH_MSG="Update version to ${{ needs.release.outputs.version || github.event.inputs.version }}"
190164
FOUND_COMMIT=$(git log --format="%H" --grep="$SEARCH_MSG" -n 1)
191-
165+
192166
if [[ -n "$FOUND_COMMIT" ]]; then
193167
echo "Found commit by message: $FOUND_COMMIT"
194168
echo "SHOULD_REVERT=true" >> $GITHUB_ENV
@@ -204,10 +178,10 @@ jobs:
204178
run: |
205179
echo "Reverting commit ${{ env.COMMIT_SHA }}..."
206180
git log --oneline -n 3
207-
181+
208182
git revert --no-commit ${{ env.COMMIT_SHA }}
209183
git status -s
210-
184+
211185
git config --global user.name 'github-actions[bot]'
212186
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
213187
git commit -m "Revert version update due to failed release"

0 commit comments

Comments
 (0)