Merge pull request #73 from catdad/capture #321
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: Build | |
on: | |
push: | |
pull_request: | |
branches: [ master ] | |
env: | |
FORCE_COLOR: 1 | |
jobs: | |
windows: | |
runs-on: windows-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm install | |
- run: npm test | |
- run: npm run package | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-artifacts | |
path: dist/*.exe | |
macos: | |
runs-on: macos-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: npm install | |
- run: npm test | |
- run: npm run package | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macos-artifacts | |
path: dist/*.dmg | |
linux: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- run: sudo apt-get install xvfb | |
- run: npm install | |
- name: Run npm test | |
run: xvfb-run --auto-servernum npm test | |
- run: npm run package | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-artifacts | |
path: dist/*.AppImage | |
release: | |
runs-on: ubuntu-latest | |
needs: [ windows, macos, linux ] | |
steps: | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./ | |
- name: Flatten artifacts | |
run: | | |
mv windows-artifacts/* . | |
mv macos-artifacts/* . | |
mv linux-artifacts/* . | |
rm -rf *artifacts | |
ls -lR | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' | |
uses: actions/github-script@v2 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs').promises; | |
console.log('environment', process.versions); | |
const { repo: { owner, repo }, sha, ref } = context; | |
console.log({ owner, repo, sha, ref }); | |
const name = ref.replace('refs/tags/', ''); | |
const release = await github.repos.createRelease({ | |
owner, repo, name, | |
tag_name: name, | |
draft: true, | |
target_commitish: sha | |
}); | |
console.log('created release', { release }); | |
for (let file of await fs.readdir('.')) { | |
console.log('uploading', file); | |
await github.repos.uploadReleaseAsset({ | |
owner, repo, | |
release_id: release.data.id, | |
name: file, | |
data: await fs.readFile(`./${file}`) | |
}); | |
} |