Build #3
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: | |
workflow_dispatch: | |
inputs: | |
node_version: | |
description: "Node.js Version" | |
required: false | |
default: "20.18.1" | |
electron_version: | |
description: "Electron Version" | |
required: false | |
default: "32.2.7" | |
env: | |
NODE_VERSION: ${{ inputs.node_version || '20.18.1' }} | |
ELECTRON_VERSION: ${{ inputs.electron_version || '32.2.7' }} | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: clone repository | |
uses: actions/checkout@v4 | |
- name: install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: install dependencies | |
run: npm install | |
- name: run build script for windows | |
if: startsWith(matrix.os,'windows') | |
shell: powershell | |
run: | | |
.\build-windows.ps1 | |
- name: run build script for ubuntu | |
if: startsWith(matrix.os,'ubuntu') | |
shell: bash | |
run: | | |
chmod +x build-linux.sh | |
./build-linux.sh | |
- name: run build script for macOS | |
if: startsWith(matrix.os,'macOS') | |
shell: bash | |
run: | | |
chmod +x build-macos.sh | |
./build-macos.sh | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-${{ matrix.os }} | |
path: prebuilds/* | |
update-version-and-release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Bump Version | |
id: bump_version | |
run: | | |
NEW_VERSION=$(date -u +"%Y%m.%d.%H%M%S") | |
echo "New version: $NEW_VERSION" | |
npm version $NEW_VERSION --no-git-tag-version | |
# Output new version for use in subsequent steps | |
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Commit Updated Version | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add package.json | |
git commit -m "chore: update version to ${{ env.new_version }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
- name: Push Changes | |
run: git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: prebuilds | |
pattern: release-* | |
merge-multiple: true | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: "v${{ env.new_version }}" | |
release_name: "Release v${{ env.new_version }}" | |
body: | | |
## Changes | |
- Automatic version bump to v${{ env.new_version }}. | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
- name: Publish to npm | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: "https://registry.npmjs.org/" | |
- name: Login to npm | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
- name: Publish Package | |
run: npm publish |