-
Notifications
You must be signed in to change notification settings - Fork 25
105 lines (85 loc) · 2.89 KB
/
createRelease.yml
File metadata and controls
105 lines (85 loc) · 2.89 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Create Github release
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'VERSION'
permissions:
contents: write
jobs:
variables:
name: Read VERSION and changelog
# if: github.repository == 'adjust/web_sdk' - commented temporary, just for testing
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
shell: bash
run: |
# Enable strict bash mode:
# -e - exit immediately if any command fails
# -u - treat unset variables as an error
# -o pipefail - fail the script if any command in a pipeline fails
set -euo pipefail
version="$(tr -d ' \t\r\n' < VERSION)"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Prepare changelog
id: prepare-changelog
run: |
set -euo pipefail
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
needs: [variables]
steps:
- uses: actions/checkout@v4
- name: Push tag
shell: bash
run: |
set -euo pipefail
VERSION="${{ needs.variables.outputs.version }}"
TAG="v$VERSION"
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Version $VERSION"
git push origin "$TAG"
- 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/*"