-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (99 loc) · 3.21 KB
/
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
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# release.yml - simple, shell-based release workflow for
# WebExtensions.
#
name: Release WebExtension
on:
push:
tags: [ "v*" ]
jobs:
release:
name: Release WebExtension
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
defaults:
run:
shell: bash -e -o pipefail {0}
steps:
- name: Check Out Sources
uses: actions/checkout@v3
- name: Determine Some Strings from Tag
run: |
# determine tag name
tagname="${{ github.ref_name }}"
# check tag name format
if [[ ! ($tagname =~ ^v(2\.[0-9]+)(\.[0-9]+)?$) ]]; then
echo "Cannot process tag \"$tagname\"." 1>&2
exit 1
fi
# determine v-prefixed version, simple version,
# extension version, XPI base name and export them
vversion=$tagname
sversion=${tagname#v}
[[ $tagname =~ ^v(2\.[0-9]+)(\.[0-9]+)?$ ]]
xversion=${BASH_REMATCH[1]}
xpibname="copy-on-select-2-unsigned-$sversion.xpi"
echo "vversion=$vversion" >> $GITHUB_ENV
echo "sversion=$sversion" >> $GITHUB_ENV
echo "xversion=$xversion" >> $GITHUB_ENV
echo "xpibname=$xpibname" >> $GITHUB_ENV
# ensure the new version is maintained in the extension
# manifest
- name: Verify Manifest
run: |
mversion=$( jq -r '.version' src/manifest.json )
if [[ $xversion != $mversion ]]; then
echo "Cannot find version \"$xversion\" in manifest." 1>&2
exit 1
fi
# ensure the new version is described in the version
# history and use its description as release description
- name: Determine Release Description
run: |
mkdir -p tmp
cat << 'EOF' > tmp/parsehist.awk
BEGIN {
invhistp = 0;
cversion = "";
versfndp = 0;
}
(! invhistp) && (/^## Version History$/) {
invhistp = 1; getline; next;
}
(! invhistp) { next; }
/^Version [0-9](\.[0-9]+)+$/ {
cversion = $2; getline; next;
}
(cversion == xversion) {
versfndp = 1; print; next;
}
END {
if ( ! versfndp ) {
print "Cannot find version \"" xversion "\" in history." > "/dev/stderr"
exit 1;
}
}
EOF
awk -v xversion="$xversion" \
-f tmp/parsehist.awk \
README.md |
# remove one trailing newline
sed -n '/^ *$/!{p;d}; $!{p;d}' > tmp/reldesc.md
- name: Create XPI
run: |
mkdir -p build
zip -jqr "build/$xpibname" src
- name: Create Release and Upload XPI
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
draft=""
if [[ $sversion != $xversion ]]; then
draft="--draft"
else
draft=""
fi
gh release create $draft \
--title "Version $sversion" \
--notes-file tmp/reldesc.md \
"$vversion" "build/$xpibname"