-
Notifications
You must be signed in to change notification settings - Fork 25
83 lines (72 loc) · 2.46 KB
/
createRelease.yml
File metadata and controls
83 lines (72 loc) · 2.46 KB
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
81
82
83
name: Create Github release
on:
workflow_dispatch:
push:
branches:
- master
paths: ['./VERSION']
jobs:
variables:
name: Read VERSION
if: github.repository == 'adjust/web_sdk'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read-file.outputs.version }}
changelog: ${{ steps.prepare-changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v4
- name: Read VERSION file
id: read-file
run: |
echo "version=$(cat ./VERSION)" >> $GITHUB_OUTPUT
- name: Prepare changelog
id: prepare-changelog
run: |
read_changelog() {
CHANGELOG_FILE="./CHANGELOG.md"
change_log_found=false
while IFS='' read -r line || [[ -n "$line" ]]; do
# If it is reading change log for the version
if $change_log_found; then
# If it reads end of change log for the version
if [[ "$line" == "---" ]]; then
break
# Append the line
else
echo "$line"
fi
# If it didn't find changelog for the version
else
# If it is the first line of change log for the version
if [[ "$line" =~ "### Version ${{ steps.read-file.outputs.version }}" ]]; then
change_log_found=true
fi
fi
done < $CHANGELOG_FILE
}
changes=$(read_changelog)
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$changes" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
prepare-release:
name: Publish Github release
if: github.repository == 'adjust/web_sdk'
runs-on: ubuntu-latest
permissions:
contents: write
needs: [variables]
steps:
- uses: actions/checkout@v4
- name: Push tag
run: |
git config --local user.name github-actions[bot]
git config --local user.email github-actions[bot]@users.noreply.github.com
git tag -a v${{ needs.variables.outputs.version }} -m "Version ${{ needs.variables.outputs.version }}"
git push origin tag v${{ needs.variables.outputs.version }}
- uses: ncipollo/release-action@v1
with:
tag: v${{ needs.variables.outputs.version }}
draft: true
name: Version ${{ needs.variables.outputs.version }}
body: ${{ needs.variables.outputs.changelog }}
artifacts: "dist/*"