Skip to content

Trigger release workflow from release commits #23

Trigger release workflow from release commits

Trigger release workflow from release commits #23

Workflow file for this run

name: Release
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
inputs:
tag_name:
description: "Existing tag to build and release, for example v0.7.0"
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }}
cancel-in-progress: false
jobs:
build-release:
name: Build Windows release
runs-on: windows-latest
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/v') || startsWith(github.event.head_commit.message, 'Release v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref }}
- name: Resolve release tag
id: release_tag
shell: pwsh
run: |
if ('${{ github.event_name }}' -eq 'workflow_dispatch') {
$tag = '${{ inputs.tag_name }}'
} elseif ('${{ github.ref }}'.StartsWith('refs/tags/')) {
$tag = '${{ github.ref_name }}'
} else {
$rootBuild = Get-Content -LiteralPath 'build.gradle.kts' -Raw
if ($rootBuild -notmatch 'val\s+javaShroudVersion\s*=\s*"([^"]+)"') {
throw 'Unable to resolve javaShroudVersion from build.gradle.kts.'
}
$tag = "v$($Matches[1])"
}
if ($tag -notmatch '^v\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?$') {
throw "Invalid release tag: $tag"
}
git fetch --force origin "refs/tags/$tag:refs/tags/$tag"
$tagSha = (git rev-list -n 1 $tag).Trim()
$headSha = (git rev-parse HEAD).Trim()
if ($tagSha -ne $headSha) {
throw "Release tag $tag points to $tagSha, but checked out commit is $headSha. Push main/dev first, then recreate the tag on the release commit."
}
"tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Setup GraalVM Native Image
uses: graalvm/setup-graalvm@v1
with:
java-version: "21"
distribution: "graalvm"
components: "native-image"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.25.4"
cache-dependency-path: desktop-app/go.sum
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Enable Corepack
shell: pwsh
run: corepack enable
- name: Install Wails CLI
shell: pwsh
run: |
go install github.com/wailsapp/wails/v2/cmd/[email protected]
$goBin = Join-Path (go env GOPATH) "bin"
$goBin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Locate Visual Studio build tools
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
if (-not $installPath) {
throw "Visual Studio C++ build tools were not found."
}
$vcvarsall = Join-Path $installPath "VC\Auxiliary\Build\vcvarsall.bat"
if (-not (Test-Path -LiteralPath $vcvarsall)) {
throw "vcvarsall.bat was not found at $vcvarsall"
}
"VCVARSALL=$vcvarsall" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Build release
shell: cmd
env:
GRAALVM_HOME: ${{ env.JAVA_HOME }}
GOEXE: go
WAILS_EXE: wails
run: build-release.bat
- name: Package release
shell: pwsh
run: Compress-Archive -Path "build\release\javashroud-windows-amd64\*" -DestinationPath "javashroud-windows-amd64.zip" -Force
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_tag.outputs.tag }}
name: JavaShroud ${{ steps.release_tag.outputs.tag }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
make_latest: true
files: javashroud-windows-amd64.zip