-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add GitHub action workflows for tests and release
- download used NSIS plugins before build and use them from that local folder - raise minimum node version (needed for building and using nodist) to 12
- Loading branch information
Showing
10 changed files
with
331 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-*' | ||
|
||
jobs: | ||
run-build: | ||
runs-on: windows-2022 | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js 16 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'npm' | ||
- run: npm ci | ||
- name: Copy Node.exe to repository directory | ||
run: Copy-Item (Get-Command node.exe | Select-Object -ExpandProperty Definition) . | ||
- run: npm test | ||
- run: npm run build | ||
- name: Create release draft | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "build/out/NodistSetup-*.exe" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: run-tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: windows-2022 | ||
|
||
strategy: | ||
matrix: | ||
node-versions: [16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- name: Copy Node.exe to repository directory | ||
run: Copy-Item (Get-Command node.exe | Select-Object -ExpandProperty Definition) . | ||
- run: npm test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ node_modules | |
/pkg | ||
/test/tmp | ||
/node.exe | ||
/build/nsis_plugins |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
import fs from 'fs'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import * as stream from 'stream'; | ||
import { fileURLToPath } from 'url'; | ||
import { promisify } from 'util'; | ||
|
||
import axios from 'axios'; | ||
import unzip from 'node-unzip-2'; | ||
|
||
const finished = promisify(stream.finished); | ||
|
||
const plugins = [ | ||
'https://nsis.sourceforge.io/mediawiki/images/7/7f/EnVar_plugin.zip', | ||
'https://nsis.sourceforge.io/mediawiki/images/4/4a/AccessControl.zip' | ||
]; | ||
|
||
async function downloadFile(url, outputLocation) { | ||
const writer = fs.createWriteStream(outputLocation); | ||
|
||
return axios.get(url, { responseType: 'stream' }).then(response => { | ||
response.data.pipe(writer); | ||
return finished(writer); | ||
}); | ||
} | ||
|
||
const dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const nsisPluginsDir = path.join(dirname, 'nsis_plugins'); | ||
const nsisPluginsInstalledFile = path.join(nsisPluginsDir, 'installed.txt'); | ||
|
||
if (fs.existsSync(nsisPluginsInstalledFile)) { | ||
console.log('NSIS plugins installed already, skipping downloading plugins'); | ||
process.exit(0); | ||
} | ||
|
||
fs.mkdirSync(nsisPluginsDir); | ||
const tmpDir = os.tmpdir(); | ||
|
||
Promise.all( | ||
plugins.map(async (url) => { | ||
const targetFileName = url.split('/').pop(); | ||
const targetPath = path.join(tmpDir, targetFileName); | ||
await downloadFile(url, targetPath); | ||
const readStream = fs.createReadStream(targetPath); | ||
const unzipped = new Promise(function(resolve, reject) { | ||
readStream.on('close', resolve); | ||
readStream.on('error', reject); | ||
}); | ||
readStream.pipe(unzip.Extract({ path: nsisPluginsDir })); | ||
await unzipped; | ||
return targetFileName; | ||
}) | ||
).then((plugins) => { | ||
fs.writeFileSync(nsisPluginsInstalledFile, 'plugins installed'); | ||
console.log('Finished downloading NSIS plugins'); | ||
plugins.forEach(plugin => console.log(` - ${plugin}`)); | ||
}); | ||
|
Oops, something went wrong.