Skip to content

Build and Release

Build and Release #2

Workflow file for this run

name: Build and Release
on:
workflow_dispatch:
jobs:
build_windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache
restore-keys: |
${{ runner.os }}-npm-cache
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Install dependencies
run: npm install
- name: Build for Windows
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run dist -- --win
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: windows-dist
path: dist/
build_linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache
restore-keys: |
${{ runner.os }}-npm-cache
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Install dependencies
run: npm install
- name: Build for Linux
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run dist -- --linux
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: linux-dist
path: dist/
build_mac:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache npm
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache
restore-keys: |
${{ runner.os }}-npm-cache
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Install dependencies
run: npm install
- name: Build for Mac
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run dist -- --mac
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: mac-dist
path: dist/
create_release:
runs-on: ubuntu-latest
needs: [build_windows, build_linux, build_mac]
if: ${{ success() }} # Ensures the job runs only if all dependent jobs succeed
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download Windows artifact
uses: actions/download-artifact@v2
with:
name: windows-dist
path: ./dist/windows
- name: Download Linux artifact
uses: actions/download-artifact@v2
with:
name: linux-dist
path: ./dist/linux
- name: Download Mac artifact
uses: actions/download-artifact@v2
with:
name: mac-dist
path: ./dist/mac
- name: Read package.json version
id: get_version
run: echo "::set-output name=version::$(jq -r .version package.json)"
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Ensure your token is correctly set up in repository secrets
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Release v${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Ensure your token is correctly set up in repository secrets
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/windows/
asset_name: windows_dist.zip
asset_content_type: application/zip
- name: Upload Release Asset (Linux)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Ensure your token is correctly set up in repository secrets
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/linux/
asset_name: linux_dist.zip
asset_content_type: application/zip
- name: Upload Release Asset (Mac)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Ensure your token is correctly set up in repository secrets
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/mac/
asset_name: mac_dist.zip
asset_content_type: application/zip