-
Notifications
You must be signed in to change notification settings - Fork 65
156 lines (156 loc) · 6.76 KB
/
pack.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Pack new version
on:
workflow_dispatch:
jobs:
publish:
environment: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update the changelog.json
run: |
DaySuffix() {
case $(date +%-d) in
1|21|31) echo "st";;
2|22) echo "nd";;
3|23) echo "rd";;
*) echo "th";;
esac
}
sudo apt-get install jq
jqCommand="jq"
manifestPath="./extension/manifest.json"
changelogPath="./extension/changelog.json"
releaseBodyFile="./releaseBody.md"
tmpFile="tmp.tmp"
readmePath="README.md"
firstEntry="$("${jqCommand}" -j ".[0]" "${changelogPath}")"
version="$(echo "$firstEntry" | "${jqCommand}" -j "[ .version | to_entries[] | .value ] | join(\".\")")"
newVersionMajor="$(echo -n "\"${version}\"" | "${jqCommand}" -j "split(\".\")[0] | tonumber | . + 1")"
newVersionMinor="$(echo -n "\"${version}\"" | "${jqCommand}" -j "split(\".\")[1] | tonumber | . + 1")"
newVersionBuild="0"
newVersionTitle="Beta"
echo "$firstEntry" | "${jqCommand}" -j "
.logs as \$clFirstEntryLogs | (
\$clFirstEntryLogs |
if ((.features | length) > 0) then
(.features |
map(\"* \" + .message + \"\n\") |
. |= [\"### Features\n\"] + . |
. |= . + [\"\n\"] |
join(\"\"))
else (\"\")
end
),
(
\$clFirstEntryLogs |
if ((.fixes | length) > 0) then
(.fixes |
map(\"* \" + .message + \"\n\") |
. |= [\"### Fixes\n\"] + . |
. |= . + [\"\n\"] |
join(\"\"))
else (\"\")
end
),
(
\$clFirstEntryLogs |
if ((.changes | length) > 0) then
(.changes |
map(\"* \" + .message + \"\n\") |
. |= [\"### Changes\n\"] + . |
. |= . + [\"\n\"] |
join(\"\"))
else (\"\")
end
),
(
\$clFirstEntryLogs |
if ((.removed | length) > 0) then
(.removed |
map(\"* \" + .message + \"\n\") |
. |= [\"### Removed\n\"] + . |
. |= . + [\"\n\"] |
join(\"\"))
else (\"\")
end
)
" >> "$releaseBodyFile"
"${jqCommand}" -j ".[0].date |= \"$(date +"%Y/%m/%d")\"" "${changelogPath}" > "${tmpFile}" && mv "${tmpFile}" "${changelogPath}"
"${jqCommand}" -j '. as $all | $all[0].logs | delpaths([keys_unsorted[] | select(($all[0].logs[.] | length) == 0) | [.]]) | . as $new | $all | .[0].logs |= $new' "${changelogPath}" > "${tmpFile}" && mv "${tmpFile}" "${changelogPath}"
cd extension && zip -q -r "../torntools_${version}.zip" . && cd ..
[ ! -d "versions" ] && mkdir versions
mv "torntools_${version}.zip" ./versions/
"${jqCommand}" -r --indent 0 "
. |=
[{
\"version\": { \"major\": ${newVersionMajor}, \"minor\": ${newVersionMinor}, \"build\": ${newVersionBuild} },
\"title\": \"${newVersionTitle}\",
\"date\": false,
\"logs\": {
\"features\": [],
\"fixes\": [],
\"changes\": [],
\"removed\": []
}
}] +
." "${changelogPath}" > "${tmpFile}" && mv "${tmpFile}" "${changelogPath}"
"${jqCommand}" -r --indent 0 ".[\"version\"] |= \"${newVersionMajor}.${newVersionMinor}.${newVersionBuild}\"" "${manifestPath}" > "${tmpFile}" && mv "${tmpFile}" "${manifestPath}"
ghReleaseDateMarkdown="[![GitHub Release Date](https://img.shields.io/static/v1?label=RELEASE%20DATE\\\\&message=$(date "+%B, %-d$(DaySuffix). %Y" | "${jqCommand}" --raw-input --raw-output '. | @uri')\\\\&color=%23acea00\\\\&style=for-the-badge)](https://github.com/Mephiles/torntools_extension/releases/latest)<!---A pointer for bash-->"
awk "/.*A pointer for bash.*/ {sub(/.*/, \"${ghReleaseDateMarkdown}\")} {print}" "${readmePath}" > "${tmpFile}" && mv "${tmpFile}" "${readmePath}"
export version
echo "version=$version" >> "$GITHUB_ENV"
- name: Format with prettier
uses: creyD/[email protected]
with:
prettier_options: --config .prettierrc --write . --list-different
- name: Upload an extension to Chrome Web Store
uses: cardinalby/[email protected]
with:
zipFilePath: versions/torntools_${{ env.version }}.zip
extensionId: 'hjpaapdjcgbmeikfnahipphknonhlhib'
apiClientId: ${{ secrets.CHROME_CLIENT_ID }}
apiClientSecret: ${{ secrets.CHROME_SECRET }}
apiRefreshToken: ${{ secrets.CHROME_REFRESH_TOKEN }}
- name: Publish an extension on Chrome Web Store
uses: cardinalby/[email protected]
id: publish_step
with:
extensionId: 'hjpaapdjcgbmeikfnahipphknonhlhib'
apiClientId: ${{ secrets.CHROME_CLIENT_ID }}
apiClientSecret: ${{ secrets.CHROME_SECRET }}
apiRefreshToken: ${{ secrets.CHROME_REFRESH_TOKEN }}
- name: Output of CWS Publish
run: |
echo "${{ steps.publish_step.outputs.publishStatus }}" >> "$GITHUB_OUTPUT"
- name: Create Firefox .xpi
id: web-ext-build
uses: kewisch/[email protected]
with:
cmd: build
source: extension
filename: "{name}-{version}.xpi"
- name: Sign Firefox .xpi
uses: kewisch/action-web-ext@v1
with:
cmd: sign
source: ${{ steps.web-ext-build.outputs.target }}
channel: unlisted
apiKey: ${{ secrets.FIREFOX_JWT_ISSUER }}
apiSecret: ${{ secrets.FIREFOX_JWT_SECRET }}
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: versions/torntools_${{ env.version }}.zip
name: "Release: v${{ env.version }}"
tag: "${{ env.version }}"
bodyFile: "./releaseBody.md"
token: ${{ secrets.GH_TOKEN }}
- name: Delete temporary files
run: |
rm -f ./releaseBody.md
rm -rf versions
- name: Add & Commit
uses: EndBug/[email protected]
with:
message: "Pack v${{ env.version }}"