Skip to content

CI for publishing windows #4

CI for publishing windows

CI for publishing windows #4

name: create-release-windows
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Optional tag (starts with `v`). Default to the tag of the selected branch.'
required: false
type: string
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: 'gradle'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Get version
id: version
run: |
$version = ./gradlew -q printInternalVersion
"VERSION=$version" >> $env:GITHUB_OUTPUT
shell: powershell
- name: Validate the tag name
run: |
if ("${{ github.event_name }}" -eq "workflow_dispatch" -and -not [string]::IsNullOrEmpty("${{ github.event.inputs.tag }}")) {
$TAG = "${{ github.event.inputs.tag }}"
} else {
$TAG = $env:GITHUB_REF -replace "refs/tags/",""
}
if ($TAG -notmatch "^v") {
Write-Error "Error: Tag ($TAG) must start with 'v'"
exit 1
}
if ($TAG -ne "v${{ steps.version.outputs.VERSION }}") {
Write-Error "Error: Git tag version ($TAG) doesn't match project version (v${{ steps.version.outputs.VERSION }})"
exit 1
}
- name: Install Node modules
run: npm install
- name: Download CodeSignTool and extract
run: |
$ProgressPreference = 'SilentlyContinue'
New-Item -ItemType Directory -Force -Path "./build-tools/codesign"
Invoke-WebRequest -Uri "https://www.ssl.com/download/codesigntool-for-windows/" -OutFile "./build-tools/CodeSignTool.zip"
Expand-Archive -Path "./build-tools/CodeSignTool.zip" -DestinationPath "./build-tools/codesign" -Force
Remove-Item "./build-tools/CodeSignTool.zip"
shell: pwsh
- name: Download wixtool 3 and extract
run: |
$ProgressPreference = 'SilentlyContinue'
New-Item -ItemType Directory -Force -Path "./build-tools/wixtool"
Invoke-WebRequest -Uri "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip" -OutFile "./build-tools/wix-binaries.zip"
Expand-Archive -Path "./build-tools/wix-binaries.zip" -DestinationPath "./build-tools/wixtool" -Force
Remove-Item "./build-tools/wix-binaries.zip"
shell: pwsh
- name: Build an MSI
run: |
export PATH="$PATH:$PWD/build-tools/wixtool"
./gradlew clean jpackage
env:
CODESIGN_TOOL_DIR: "./build-tools/codesign"
SSL_COM_USERNAME: ${{ secrets.SSL_COM_USERNAME }}
SSL_COM_PASSWORD: ${{ secrets.SSL_COM_PASSWORD }}
SSL_COM_TOTP_SECRET: ${{ secrets.SSL_COM_TOTP_SECRET }}
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: true
files: ./build/msi/*.msi
overwrite_files: true
fail_on_unmatched_files: true
generate_release_notes: true
tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}