Skip to content

Commit 2baeddd

Browse files
authored
Create an "Update Version" GitHub action
This PR creates a GitHub action that automates updating the Swift Testing library's version.
1 parent 1be6b35 commit 2baeddd

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Update Swift Testing version
2+
3+
on:
4+
workflow_dispatch:
5+
# Inputs the workflow accepts.
6+
inputs:
7+
version:
8+
description: 'Swift version (e.g. 5.0.1)'
9+
required: true
10+
type: string
11+
isRelease:
12+
description: 'Is this a release branch?'
13+
required: true
14+
type: boolean
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
create-pr:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
pull-requests: write
23+
steps:
24+
- name: Creating and pushing branch from ${{ github.ref }}...
25+
run: |
26+
git checkout -b "$GITHUB_ACTOR/update-version.txt"
27+
if [ $SWT_IS_RELEASE -eq "false" ]; then
28+
export SWT_VERSION="$SWT_VERSION"-dev
29+
fi
30+
echo "$SWT_VERSION" > VERSION.txt
31+
git add VERSION.txt &&
32+
git commit -m "Update branch version" &&
33+
git push -u origin HEAD
34+
env:
35+
SWT_VERSION: ${{ github.event.inputs.version }}
36+
SWT_IS_RELEASE: ${{ github.event.inputs.isRelease }}
37+
- name: Creating pull request...
38+
run: gh pr create -B base_branch -H branch_to_merge \
39+
--title "Update version to $SWT_VERSION" \
40+
--body "This PR updates the Swift Testing version on branch $GITHUB_REF to $SWT_VERSION. This PR was auto-generated. A code owner must review it before it can be merged."
41+
env:
42+
SWT_VERSION: ${{ github.event.inputs.version }}
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)