tiny-rdm/.github/workflows/release-windows.yaml

108 lines
4.1 KiB
YAML
Raw Normal View History

2023-08-10 17:26:55 +08:00
name: Release Windows App
on:
release:
types: [ published ]
jobs:
release:
name: Release Windows App
runs-on: windows-latest
strategy:
matrix:
platform:
- windows/amd64
2024-02-22 00:10:48 +08:00
- windows/arm64
2023-08-10 17:26:55 +08:00
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Normalise platform tag
id: normalise_platform
shell: bash
run: |
2024-02-22 00:10:48 +08:00
tag=$(echo ${{ matrix.platform }} | sed -e 's/\//_/g' -e 's/amd64/x64/g')
2023-08-10 17:26:55 +08:00
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Normalise version tag
id: normalise_version
shell: bash
run: |
version=$(echo ${{ github.event.release.tag_name }} | sed -e 's/v//g')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: stable
- name: Install chocolatey
2023-08-10 17:26:55 +08:00
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install nsis jq upx
2023-08-10 17:26:55 +08:00
- name: Install wails
shell: bash
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
- name: Setup Node
2023-08-16 16:52:02 +08:00
uses: actions/setup-node@v3
2023-08-10 17:26:55 +08:00
with:
node-version: 18
2023-08-10 17:26:55 +08:00
- name: Build frontend assets
shell: bash
run: |
npm install -g npm@9
2023-08-10 17:26:55 +08:00
jq '.info.productVersion = "${{ steps.normalise_version.outputs.version }}"' wails.json > tmp.json
mv tmp.json wails.json
cd frontend
jq '.version = "${{ steps.normalise_version.outputs.version }}"' package.json > tmp.json
mv tmp.json package.json
npm install
2023-08-10 17:26:55 +08:00
- name: Build Windows portable app
shell: bash
run: |
CGO_ENABLED=1 wails build -clean -platform ${{ matrix.platform }} \
2024-02-22 00:10:48 +08:00
-webview2 embed \
-ldflags "-X main.version=${{ github.event.release.tag_name }} -X main.gaMeasurementID=${{ secrets.GA_MEASUREMENT_ID }} -X main.gaSecretKey=${{ secrets.WINDOWS_GA_SECRET }}"
2023-08-10 17:26:55 +08:00
- name: Compress portable binary
working-directory: ./build/bin
2023-08-19 19:11:46 +08:00
run: Compress-Archive "Tiny RDM.exe" tiny-rdm.zip
2023-08-10 17:26:55 +08:00
2024-02-22 00:10:48 +08:00
- name: Rename zip package
2023-08-19 19:11:46 +08:00
working-directory: ./build/bin
2024-02-22 00:10:48 +08:00
run: Rename-Item -Path "tiny-rdm.zip" -NewName "TinyRDM_Portable_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.zip"
- name: Upload release asset (Portable)
uses: softprops/action-gh-release@v1
with:
files: ./build/bin/TinyRDM_Portable_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.zip
token: ${{ secrets.GITHUB_TOKEN }}
2023-08-10 17:26:55 +08:00
- name: Build Windows NSIS installer
shell: bash
2024-02-22 00:10:48 +08:00
run: CGO_ENABLED=1 wails build -clean -platform ${{ matrix.platform }} -nsis -webview2 embed -ldflags "-X main.version=${{ github.event.release.tag_name }}"
2023-08-10 17:26:55 +08:00
- name: Codesign Windows NSIS installer
2023-08-19 19:11:46 +08:00
working-directory: ./build/bin
2023-08-10 17:26:55 +08:00
run: |
echo "Creating certificate file"
New-Item -ItemType directory -Path certificate
Set-Content -Path certificate\certificate.txt -Value '${{ secrets.WIN_SIGNING_CERT }}'
certutil -decode certificate\certificate.txt certificate\certificate.pfx
echo "Signing TinyRDM installer"
2024-02-22 00:10:48 +08:00
& 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /fd sha256 /tr http://ts.ssl.com /f certificate\certificate.pfx /p '${{ secrets.WIN_SIGNING_CERT_PASSWORD }}' TinyRDM-${{ steps.normalise_platform.outputs.tag }}-installer.exe
- name: Rename installer
working-directory: ./build/bin
run: Rename-Item -Path "TinyRDM-${{ steps.normalise_platform.outputs.tag }}-installer.exe" -NewName "TinyRDM_Setup_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.exe"
2023-08-10 17:26:55 +08:00
- name: Upload release asset (Installer)
2024-02-22 00:10:48 +08:00
uses: softprops/action-gh-release@v1
with:
files: ./build/bin/TinyRDM_Setup_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.exe
token: ${{ secrets.GITHUB_TOKEN }}