-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (83 loc) · 2.97 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
name: Release
on:
push:
tags:
- '*'
jobs:
build_and_sign:
name: 'Build and sign'
runs-on: ubuntu-latest
steps:
- name: Checkout Git repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'
- name: Build with NPM
run: |-
npm install
npm run build:all
- name: Sign
shell: bash
env:
SIGNING_PRIVATE_KEY: ${{ secrets.SIGNING_PRIVATE_KEY_WITHOUT_HEADER_FOOTER }}
run: |
chmod +x ./sign.sh
./sign.sh ./dist/standard/YoutubeScript.js ./dist/standard/YoutubeConfig.json
./sign.sh ./dist/uses-alternative-metadata/YoutubeScript.js ./dist/uses-alternative-metadata/YoutubeConfig.json
- name: Archive output
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
release:
name: 'Create draft release'
runs-on: ubuntu-latest
needs: [ build_and_sign ]
permissions:
contents: write # needed to create GitHub Release
steps:
- name: Download output artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Get version major from tag
id: get_version_major_from_tag
uses: actions/github-script@v7
with:
script: |
const upstreamReleaseVersion = '${{ github.ref_name }}'.split('-')[0];
console.log('Version major:', upstreamReleaseVersion);
return upstreamReleaseVersion;
result-encoding: string
- name: Create draft release and upload plugin files
id: create_release
uses: actions/github-script@v7
with:
script: |
const path = require('node:path');
const fs = require('node:fs/promises');
const release = await github.rest.repos.createRelease({
... context.repo,
name: 'YouTube with DeArrow (v${{ steps.get_version_major_from_tag.outputs.result }})',
draft: true,
tag_name: '${{ github.ref_name }}',
generate_release_notes: true
});
console.log('Draft release created:', release.data.html_url);
for (const releaseType of ['standard', 'uses-alternative-metadata']) {
for (const fileName of [`YoutubeConfig_${releaseType}.json`, `YoutubeScript_${releaseType}.js`]) {
console.log(`[${releaseType}] Uploading ${fileName} asset to draft release`);
const data = await fs.readFile(`dist/${releaseType}/${fileName}`);
await github.rest.repos.uploadReleaseAsset({
... context.repo,
release_id: release.data.id,
name: fileName,
data
});
console.log(`[${releaseType}] ${fileName} uploaded to draft release`);
}
}