-
-
Notifications
You must be signed in to change notification settings - Fork 12
147 lines (125 loc) · 5.2 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
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
name: release
on:
push:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: install node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache node dependencies
uses: actions/cache@v4
env:
cache-name: cache-dependencies
with:
path: |
~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: install node dependencies
run: npm install
- name: build
run: npm run build
release:
runs-on: ubuntu-latest
needs: test
# only trigger when tagged with a version
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: install node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache node dependencies
uses: actions/cache@v4
env:
cache-name: cache-dependencies
with:
path: |
~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: install node dependencies
run: npm install
- name: build
run: npm run build
- name: release
run: |
npm run release -- --no-increment --no-git --github.release --ci --VV
sleep 1s
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: upload update.json
uses: actions/github-script@v7
env:
FILES: build/update*.json
ARTEFACT_NAME_INPUT: "${{ inputs.artefactName }}"
RELEASE_TAG: 'update'
with:
debug: true
script: |
const path = require('path');
const fs = require('fs');
const __dirname = path.resolve()
console.log('searching for release...')
var { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: process.env.RELEASE_TAG,
});
console.log("found release " + release.name)
console.log('doing globbing option');
const globOptions = {
followSymbolicLinks: 'FALSE'
}
const files = process.env.FILES.split(os.EOL);
const globber = await glob.create(files.join('\n'), globOptions)
for await (const file of globber.globGenerator()) {
console.log(file)
fs.readFile(file, 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
const fileName = file.split("/").pop();
const asset = release.assets.filter(asset=>asset.name == fileName);
if(asset.length > 0){
github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id
});
}
console.log('write to '+ release.id)
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
name: fileName,
data: data
});
});
}
- name: Notify release
uses: apexskier/github-release-commenter@v1
continue-on-error: true
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment-template: |
:rocket: _This ticket has been resolved in {release_tag}. See {release_link} for release notes._