-
Notifications
You must be signed in to change notification settings - Fork 142
193 lines (161 loc) · 7.13 KB
/
AutoRelease.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# This workflow will release a new developer build version on github
name: Auto release developer-build
on:
push:
branches: [ ExperimentalTabMode ]
workflow_dispatch:
inputs:
version:
description: 'Define release "milestone" "majore" "minore" or "dev"'
required: true
default: 'dev'
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Increase Version in manifest.json
shell: cmd
run: |
set version=${{ github.event.inputs.version }}
Get-Command "jq.exe"
jq.exe --version
echo do some git configuration
git config user.name github-actions
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git status
git branch --show-current > git_branch.txt
set /p var_git_branch=<git_branch.txt
if NOT "ExperimentalTabMode"=="%var_git_branch%" (
echo this workflow only works in the ExperimentalTabMode branch
exit 1
)
echo extract version numbers
jq.exe (.version^|split(\".\")^|map(tonumber)^|.[0]) < plugin/manifest.json > milestone_version.txt
jq.exe (.version^|split(\".\")^|map(tonumber)^|.[1]) < plugin/manifest.json > majore_version.txt
jq.exe (.version^|split(\".\")^|map(tonumber)^|.[2]) < plugin/manifest.json > minore_version.txt
jq.exe (.version^|split(\".\")^|map(tonumber)^|.[3]) < plugin/manifest.json > dev_version.txt
set /p var_mil=<milestone_version.txt
set /p var_maj=<majore_version.txt
set /p var_min=<minore_version.txt
set /p var_dev=<dev_version.txt
jq.exe -r (.version^|split(\".\")^|map(tonumber)^|(.[0]^|=%var_mil%)^|(.[1]^|=%var_maj%)^|(.[2]^|=%var_min%)^|(.[3]^|=0)^|map(tostring)^|join(\".\")) < plugin/manifest.json > old_change_log_version.txt
set /p var_old_change_log_version=<old_change_log_version.txt
echo save old_change_log_version with %var_old_change_log_version%
if "milestone"=="%version%" (
echo if milestone
set /A var_mil+=1
set var_maj=0
set var_min=0
set var_dev=0
) else (
if "majore"=="%version%" (
echo if majore
set /A var_maj+=1
set var_min=0
set var_dev=0
) else (
if "minore"=="%version%" (
echo if minore
set /A var_min+=1
set var_dev=0
) else (
echo else dev
set /A var_dev+=1
)
)
)
echo save complete version number in new_version.txt
jq.exe (.version^|split(\".\")^|map(tonumber)^|(.[0]^|=%var_mil%)^|(.[1]^|=%var_maj%)^|(.[2]^|=%var_min%)^|(.[3]^|=%var_dev%)^|map(tostring)^|join(\".\")) < plugin/manifest.json > new_version.txt
set /p var_build=<new_version.txt
echo save new_manifest.json with new version number %var_build%
jq.exe (.version^|=\"%var_build%\") plugin/manifest.json > new_manifest.json
echo move new_manifest.json to manifest.json
move /y new_manifest.json plugin/manifest.json
echo cleanup new_version.txt
jq.exe -r . new_version.txt > new_clean_version.txt
echo npm install/ run
- run: npm install
- run: npm run lint
- name: commit/ push git changes
shell: cmd
run: |
echo commit git changes
set /p var_build=<new_version.txt
git status
git add plugin/manifest.json
git commit -m "Auto version bump for Version %var_build%"
git push
git rev-parse --verify HEAD > commit_sha.txt
- name: Release latest developer build
shell: cmd
run: |
set version=${{ github.event.inputs.version }}
set /p var_build=<new_clean_version.txt
set /p var_old_change_log_version=<old_change_log_version.txt
set /p var_commit_sha=<commit_sha.txt
if "0.0.0.0" == "%var_old_change_log_version%" (
set var_old_change_log_version=0.0.0.160
)
if "milestone"=="%version%" (
set normal_release=1
) else (
if "majore"=="%version%" (
set normal_release=1
) else (
if "minore"=="%version%" (
set normal_release=1
) else (
set normal_release=0
)
)
)
echo rename release files
cd eslint
move /y WebToEpub%var_build%.xpi WebToEpub%var_build%.Firefox.zip
move /y WebToEpub%var_build%.zip WebToEpub%var_build%.Chrome.zip
cd ..
if %normal_release% == 1 (
echo Create release notes.
echo ## What's Changed> output.txt
echo.>> output.txt
echo placeholder >> output.txt
echo.>> output.txt
echo ## New Contributors>> output.txt
echo.>> output.txt
echo placeholder >> output.txt
echo.>> output.txt
echo **Full Changelog**: https://github.com/dteviot/WebToEpub/compare/%var_old_change_log_version%...%var_build% >> output.txt
echo create %var_build% release:
gh release create %var_build% --latest -t "Release %var_build%" --target "ExperimentalTabMode" -F output.txt
echo add files to release.
gh release upload %var_build% eslint/WebToEpub%var_build%.Firefox.zip
gh release upload %var_build% eslint/WebToEpub%var_build%.Chrome.zip
) else (
echo Create developer-build release notes.
echo Latest developer build of WebToEpub with the latest fixes. > output.txt
echo To install the Addon pick the file suitable for you, >> output.txt
echo * WebToEpub%var_build%.Firefox.zip for Firefox >> output.txt
echo * WebToEpub%var_build%.Chrome.zip for Chrome >> output.txt
echo.>> output.txt
echo follow the "How to install from Source (for people who are not developers)" instructions at: https://github.com/dteviot/WebToEpub/tree/ExperimentalTabMode#user-content-how-to-install-from-source-for-people-who-are-not-developers>> output.txt
echo.>> output.txt
echo **Full Changelog**: https://github.com/dteviot/WebToEpub/compare/%var_old_change_log_version%...developer-build >> output.txt
echo delete old developer-build release:
gh release delete developer-build --cleanup-tag
echo create developer-build release:
gh release create developer-build -p -t "Latest developer build" --target "ExperimentalTabMode" -F output.txt
echo add files to release.
gh release upload developer-build eslint/WebToEpub%var_build%.Firefox.zip
gh release upload developer-build eslint/WebToEpub%var_build%.Chrome.zip
)
env:
GH_TOKEN: ${{ github.token }}