-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions workflow for build and release process
- Loading branch information
Showing
1 changed file
with
86 additions
and
0 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,86 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Get version from package.json | ||
id: package_version | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const package = require('./package.json') | ||
const version = package.version | ||
core.setOutput('version', version) | ||
- name: Check if tag exists | ||
id: check_tag | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const version = '${{ steps.package_version.outputs.version }}' | ||
const tag = `v${version}` | ||
try { | ||
await github.rest.git.getRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${tag}` | ||
}) | ||
core.setOutput('exists', 'true') | ||
} catch (error) { | ||
if (error.status === 404) { | ||
core.setOutput('exists', 'false') | ||
} else { | ||
throw error | ||
} | ||
} | ||
- name: Create Git tag | ||
if: steps.check_tag.outputs.exists == 'false' | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
git tag v${{ steps.package_version.outputs.version }} | ||
git push origin v${{ steps.package_version.outputs.version }} | ||
- name: Build application | ||
if: steps.check_tag.outputs.exists == 'false' | ||
run: npm run build | ||
|
||
- name: Create Release | ||
if: steps.check_tag.outputs.exists == 'false' | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
with: | ||
tag_name: v${{ steps.package_version.outputs.version }} | ||
name: Release v${{ steps.package_version.outputs.version }} | ||
draft: false | ||
prerelease: false | ||
files: | | ||
dist/*.msi | ||
body: | | ||
Release v${{ steps.package_version.outputs.version }} | ||
Installation: | ||
- Download the .msi file | ||
- Run the installer | ||
- Follow the installation wizard |