Skip to content

Commit 8c7e883

Browse files
theRealRobGrmigneco
authored andcommitted
Adding actions for generating and publishing a release
The generate-release action is a manual dispatch action that takes the version number as an input, and depending on the major version, will checkout either main or main_1.x, then merge either develop or develop_1.x into it, bump all the version strings in the repo, and raise a PR against main or main_1.x. The publish-release action runs on merge to main or main_1.x and reads the version from the version.txt file to determine the release tag it should publish, then publishes that release. NOTE: both of these actions are broken in v2 of the repo until we bring it up to date with the Swift Package Manager support changes, as the version.txt file does not exist in develop currently.
1 parent 263f3c7 commit 8c7e883

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Generate Release
2+
run-name: Generate Release ${{ fromJSON(inputs.major) }}.${{ fromJSON(inputs.minor) }}.${{ fromJSON(inputs.patch) }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
major:
8+
description: 'Major version'
9+
required: true
10+
default: '1'
11+
type: choice
12+
options:
13+
- '1'
14+
- '2'
15+
minor:
16+
description: 'Minor version'
17+
required: true
18+
type: number
19+
patch:
20+
description: 'Patch version'
21+
required: true
22+
type: number
23+
24+
jobs:
25+
bump-version-and-raise-pr:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write
29+
pull-requests: write
30+
env:
31+
version: ${{ fromJSON(inputs.major) }}.${{ fromJSON(inputs.minor) }}.${{ fromJSON(inputs.patch) }}
32+
branch: ${{ inputs.major == 2 && 'develop' || 'develop_1.x' }}
33+
target: ${{ inputs.major == 2 && 'main' || 'main_1.x' }}
34+
steps:
35+
- name: Check minor has no decimals
36+
run: ${{ !contains(fromJSON(inputs.minor), '.') }}
37+
38+
- name: Check patch has no decimals
39+
run: ${{ !contains(fromJSON(inputs.patch), '.') }}
40+
41+
- name: Checkout ${{ env.target }}
42+
uses: actions/checkout@v4
43+
with:
44+
ref: ${{ env.target }}
45+
fetch-depth: 0
46+
47+
- name: Ensure tag does not exist
48+
run: |
49+
if git show-ref --tags --verify --quiet "refs/tags/$version"; then
50+
echo "::error::Tag $version exists" && exit 1
51+
else
52+
echo "Tag $version does not exist"
53+
fi
54+
55+
- name: Ensure branch does not exist
56+
run: |
57+
if git show-ref --verify --quiet "refs/remotes/origin/release/$version"; then
58+
echo "::error::Release branch release/$version exists" && exit 1
59+
else
60+
echo "Release branch release/$version does not exist"
61+
fi
62+
63+
- name: Merge in ${{ env.branch }}
64+
run: |
65+
git config user.name github-actions
66+
git config user.email [email protected]
67+
git merge origin/${{ env.branch }}
68+
69+
- name: Update version in txt file
70+
run: sed -i "s/[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}/$version/" ./mambaSharedFramework/Resources/version.txt
71+
72+
- name: Update version in xcodeproj file
73+
run: sed -i "s/MARKETING_VERSION = [0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\};/MARKETING_VERSION = $version;/" ./mamba.xcodeproj/project.pbxproj
74+
75+
- name: Update version in podspec file
76+
run: sed -i "s/= \"[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\"/= \"$version\"/" ./mamba.podspec
77+
78+
- name: Create pull request
79+
uses: peter-evans/create-pull-request@v7
80+
with:
81+
title: Release ${{ env.version }}
82+
commit-message: Bump version to ${{ env.version }}
83+
branch: release/${{ env.version }}
84+
body: |
85+
Automated version bump to ${{ env.version }} generated by [create-pull-request][1].
86+
87+
[1]: https://github.com/peter-evans/create-pull-request

.github/workflows/publish-release.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish Release
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- 'main_1.x'
7+
8+
jobs:
9+
get-version:
10+
name: Get version for release
11+
runs-on: ubuntu-latest
12+
outputs:
13+
version: ${{ steps.version.outputs.version }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- id: version
18+
run: echo "version=`cat ./mambaSharedFramework/Resources/version.txt`" >> "$GITHUB_OUTPUT"
19+
20+
publish-release:
21+
name: Publish release ${{ needs.get-version.outputs.version }}
22+
runs-on: ubuntu-latest
23+
needs: get-version
24+
permissions:
25+
contents: write
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Create release
29+
uses: elgohr/Github-Release-Action@v5
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
title: ${{ needs.get-version.outputs.version }}
34+
tag: ${{ needs.get-version.outputs.version }}

0 commit comments

Comments
 (0)