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

102 lines
3.9 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
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Normalise platform tag
id: normalise_platform
shell: bash
run: |
tag=$(echo ${{ matrix.platform }} | sed -e 's/\//_/g')
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:
2023-08-16 16:52:02 +08:00
node-version: 16
2023-08-10 17:26:55 +08:00
- name: Build frontend assets
shell: bash
run: |
npm install -g npm
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 }} -upx -webview2 embed -ldflags "-X main.version=${{ github.event.release.tag_name }}"
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
- name: Upload release asset (Portable)
shell: bash
2023-08-19 19:11:46 +08:00
working-directory: ./build/bin
2023-08-10 17:26:55 +08:00
run: |
filepath="tiny-rdm.zip"
filename="TinyRDM_Portable_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.zip"
upload_url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ github.event.release.id }}/assets"
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/zip" --data-binary @$filepath "$upload_url?name=$filename"
- name: Build Windows NSIS installer
shell: bash
run: CGO_ENABLED=1 wails build -clean -platform ${{ matrix.platform }} -nsis -upx -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"
& '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-amd64-installer.exe
- name: Upload release asset (Installer)
shell: bash
2023-08-19 19:11:46 +08:00
working-directory: ./build/bin/
2023-08-10 17:26:55 +08:00
run: |
filepath="TinyRDM-amd64-installer.exe"
filename="TinyRDM_Setup_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.exe"
upload_url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ github.event.release.id }}/assets"
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/octet-stream" --data-binary @$filepath "$upload_url?name=$filename"