-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (82 loc) · 3.38 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
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
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: Handle update files
run: |
echo "Updating update manifests for $BASE_NAME-$VERSION"
updatelink="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${VERSION}/${BASE_NAME}-${VERSION}.xpi"
update_hash="sha256:$(shasum -a 256 "${BUILD_DIR}/${BASE_NAME}-${VERSION}.xpi" | cut -d' ' -f1)"
jq --arg version "$VERSION" \
--arg updatelink "$updatelink" \
--arg updatehash "$update_hash" \
--arg pluginID "$PLUGIN_ID" \
'.addons[$pluginID].updates[0].version = $version |
.addons[$pluginID].updates[0].update_link = $updatelink |
.addons[$pluginID].updates[0].update_hash = $updatehash' \
"$UPDATE_TEMPLATE_FILE" > "$UPDATE_JSON_FILE"
cp "$UPDATE_JSON_FILE" "$UPDATE_RDF_FILE"
# Commit changes if any
git add "$UPDATE_JSON_FILE" "$UPDATE_RDF_FILE"
if ! git diff-index --quiet HEAD -- "$UPDATE_JSON_FILE" "$UPDATE_RDF_FILE"; then
git commit -m "Update $UPDATE_JSON_FILE and $UPDATE_RDF_FILE"
fi
git push
- 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}