Merge branch 'feature/dearrow' into with-dearrow #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`); | |
} | |
} |