Skip to content

Update GitHub Actions build workflow to enhance permissions and impro… #15

Update GitHub Actions build workflow to enhance permissions and impro…

Update GitHub Actions build workflow to enhance permissions and impro… #15

Workflow file for this run

name: Build and Release
on:
push:
branches:
- master
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- 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 --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.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.GITHUB_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