Skip to content

Commit f4f086d

Browse files
authored
Merge pull request #16 from NakaokaRei/codex/manual-release-dispatch
Run releases through manual dispatch
2 parents 779986d + 001fbec commit f4f086d

1 file changed

Lines changed: 83 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,98 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- "*"
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Marketing version and tag (for example: 0.3.0)"
8+
required: true
9+
type: string
710

811
permissions:
912
contents: write
1013

14+
concurrency:
15+
group: release
16+
cancel-in-progress: false
17+
1118
jobs:
1219
release:
1320
runs-on: macos-26
1421
timeout-minutes: 30
1522

1623
steps:
1724
- uses: actions/checkout@v6
25+
with:
26+
ref: main
27+
fetch-depth: 0
28+
29+
- name: Validate version
30+
env:
31+
VERSION: ${{ inputs.version }}
32+
run: |
33+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
34+
echo "::error::Version must use the x.y.z format."
35+
exit 1
36+
fi
37+
38+
if git rev-parse --verify --quiet "refs/tags/$VERSION"; then
39+
echo "::error::Tag $VERSION already exists."
40+
exit 1
41+
fi
42+
43+
- name: Update marketing version
44+
env:
45+
VERSION: ${{ inputs.version }}
46+
run: |
47+
ruby <<'RUBY'
48+
path = "TrackpadAir.xcodeproj/project.pbxproj"
49+
project = File.read(path)
50+
version = ENV.fetch("VERSION")
51+
updated_configurations = 0
52+
53+
updated_project = project.gsub(
54+
/(\w+ \/\* (?:Debug|Release) \*\/ = \{\n\s+isa = XCBuildConfiguration;.*?\n\s+\};)/m
55+
) do |configuration|
56+
unless configuration.include?("PRODUCT_BUNDLE_IDENTIFIER = com.TrackpadAir;")
57+
next configuration
58+
end
59+
60+
updated_configuration = configuration.sub(
61+
/MARKETING_VERSION = [^;]+;/,
62+
"MARKETING_VERSION = #{version};"
63+
)
64+
65+
if updated_configuration == configuration
66+
abort "MARKETING_VERSION was not found in an app build configuration"
67+
end
68+
69+
updated_configurations += 1
70+
updated_configuration
71+
end
72+
73+
unless updated_configurations == 2
74+
abort "Expected to update 2 app build configurations, updated #{updated_configurations}"
75+
end
76+
77+
File.write(path, updated_project)
78+
RUBY
79+
80+
- name: Push version and tag
81+
env:
82+
VERSION: ${{ inputs.version }}
83+
run: |
84+
if git diff --quiet -- TrackpadAir.xcodeproj/project.pbxproj; then
85+
echo "::error::Marketing version is already $VERSION."
86+
exit 1
87+
fi
88+
89+
git config user.name "github-actions[bot]"
90+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
91+
git add TrackpadAir.xcodeproj/project.pbxproj
92+
git commit -m "Bump version to $VERSION"
93+
git push origin HEAD:main
94+
git tag "$VERSION"
95+
git push origin "$VERSION"
1896
1997
- name: Import signing certificate
2098
env:
@@ -63,8 +141,9 @@ jobs:
63141
- name: Create GitHub release
64142
env:
65143
GH_TOKEN: ${{ github.token }}
144+
VERSION: ${{ inputs.version }}
66145
run: |
67-
gh release create "$GITHUB_REF_NAME" \
146+
gh release create "$VERSION" \
68147
TrackpadAir.app.zip \
69148
--generate-notes \
70149
--verify-tag

0 commit comments

Comments
 (0)