generated from snow-actions/composite-action-template
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (73 loc) · 2.32 KB
/
increment-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Increment version
on:
workflow_dispatch:
inputs:
increment-version:
description: Increment version (Semantic Versioning)
required: true
default: patch
type: choice
options:
- major
- minor
- patch
jobs:
increment-version:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Latest version
run: |
set -x
tag=$(gh api /repos/${GITHUB_REPOSITORY}/releases/latest --jq '.tag_name')
echo "LATEST_VERSION=$tag" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}
- name: Next version
id: next-version
run: |
set -x
if [[ ${LATEST_VERSION} =~ ^(.*?)([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
prefix=${BASH_REMATCH[1]}
major=${BASH_REMATCH[2]}
minor=${BASH_REMATCH[3]}
patch=${BASH_REMATCH[4]}
else
exit 1
fi
case "$INCREMENT_VERSION" in
"major")
((++major)); minor=0; patch=0;;
"minor")
((++minor)); patch=0;;
"patch")
((++patch));;
esac
next_version="${prefix}${major}.${minor}.${patch}"
echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV
env:
INCREMENT_VERSION: ${{ github.event.inputs.increment-version }}
- uses: actions/checkout@v3
- name: Update README
id: version
run: |
set -x
sed -i -e "s|${GITHUB_REPOSITORY}@${LATEST_VERSION}|${GITHUB_REPOSITORY}@${NEXT_VERSION}|g" README.md
git diff
- uses: snow-actions/git-config-user@v1.0.0
- id: generate-token
uses: tibdex/github-app-token@v1.7.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Commit & PR
run: |
set -x
branch="release/${NEXT_VERSION}"
git switch -c ${branch}
git add .
git commit -m "${NEXT_VERSION}"
git push origin ${branch}
gh pr create --base ${GITHUB_REF_NAME} --head ${branch} --assignee ${GITHUB_ACTOR} --title ${NEXT_VERSION} --body ''
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}