-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (62 loc) · 2.23 KB
/
create-release.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
name: Create Release
on:
push:
branches:
- main
paths:
- 'src/manifest.json'
workflow_dispatch: # allows to manually trigger the workflow_dispatch
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt install jq
- name: Set up Git user
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Load .env file
run: |
set -o allexport
source .env
set +o allexport
# Export all loaded variables to GITHUB_ENV
for var in $(cat .env | grep -v '^#' | xargs); do
echo "$var" >> $GITHUB_ENV
done
- name: Extract version number
id: extract_version
run: echo "VERSION=$(jq -r '.version' src/manifest.json)" >> $GITHUB_ENV
- name: Check changelog for version entry
run: |
if ! grep -q "## v${VERSION}" "${CHANGELOG}"; then
echo "Error: ${CHANGELOG} does not contain a heading for version v${VERSION}."
exit 1
fi
- name: Build release
run: |
echo "Building release ${BASE_NAME}-$VERSION"
chmod +x scripts/build.sh
scripts/build.sh ${BASE_NAME} $VERSION
echo "Built release ${BASE_NAME}-$VERSION"
- name: Get release notes
run: |
echo "Extract release notes from ${CHANGELOG}"
echo "## Changes" >> release-notes-${VERSION}.md
sed -n "/## v${VERSION}/,/^## /p" ${CHANGELOG} | sed '1d;$d' >> release-notes-${VERSION}.md
echo "Extracted release notes from ${CHANGELOG}"
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Creating release $VERSION"
gh release create v${VERSION} ${BUILD_DIR}/${BASE_NAME}-${VERSION}.xpi -t "v${VERSION}" --notes-file release-notes-${VERSION}.md
echo "Created release $VERSION"
- name: Cleanup
run: |
rm release-notes-${VERSION}.md
rm -rf ${BUILD_DIR}