-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (116 loc) · 4.24 KB
/
Copy pathrelease.yml
File metadata and controls
134 lines (116 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Release Daily App
on:
push:
tags:
- 'v*' # Trigger on tags starting with 'v'
jobs:
# Read the TOML file first and provide its info to other jobs
prepare:
runs-on: ubuntu-latest
outputs:
app_name: ${{ steps.get_info.outputs.name }}
app_version: ${{ steps.get_info.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Get app info from FyneApp.toml
id: get_info
run: |
APP_NAME=$(grep '^ Name' FyneApp.toml | awk -F'=' '{print $2}' | tr -d ' "')
APP_VERSION=$(grep '^ Version' FyneApp.toml | awk -F'=' '{print $2}' | tr -d ' "')
echo "App Name: $APP_NAME"
echo "App Version: $APP_VERSION"
# Make the info available to other jobs as outputs
echo "name=$APP_NAME" >> $GITHUB_OUTPUT
echo "version=$APP_VERSION" >> $GITHUB_OUTPUT
- name: Validate version matches tag
run: |
# Ensure the version in FyneApp.toml has been updated before tagging a new release
tag_version="${{ github.ref_name }}"
file_version="v${{ steps.get_info.outputs.version }}"
echo "Git Tag: $tag_version"
echo "TOML Version: $file_version"
if [ "$tag_version" != "$file_version" ]; then
echo "Error: Git tag ($tag_version) does not match the version in FyneApp.toml ($file_version)"
exit 1
fi
build:
# Use a build matrix to build on all three platforms
needs: prepare
strategy:
matrix:
goos: [ linux, windows, darwin ]
include:
- goos: linux
os: ubuntu-latest
- goos: windows
os: windows-latest
- goos: darwin
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.work
- name: Create client.json from secret
shell: bash
env:
CLIENT_SECRET_JSON: ${{ secrets.CLIENT_SECRET_JSON }}
run: |
if [ -z "$CLIENT_SECRET_JSON" ]; then
echo "CLIENT_SECRET_JSON secret is not set. Aborting."
exit 1
fi
mkdir -p secrets
echo "$CLIENT_SECRET_JSON" > secrets/client.json
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev xorg-dev
- name: Install Fyne
run: go install fyne.io/tools/cmd/fyne@latest
- name: Build and package
run: fyne package -os ${{ matrix.goos }} -release
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: app-${{ matrix.goos }}
path: "${{ needs.prepare.outputs.app_name }}.*"
if-no-files-found: error
release:
needs: [ prepare, build ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Prepare artifacts
run: |
APP_NAME="${{ needs.prepare.outputs.app_name }}"
APP_VERSION="${{ needs.prepare.outputs.app_version }}"
# linux
mv "dist/app-linux/$APP_NAME.tar.xz" "dist/$APP_NAME-$APP_VERSION-linux.tar.xz"
# mac
zip -r "dist/$APP_NAME-$APP_VERSION-mac.zip" "dist/app-darwin/$APP_NAME.app"
# windows
zip "dist/$APP_NAME-$APP_VERSION-win.exe.zip" "dist/app-windows/$APP_NAME.exe"
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
APP_NAME="${{ needs.prepare.outputs.app_name }}"
APP_VERSION="${{ needs.prepare.outputs.app_version }}"
gh release create ${{ github.ref }} \
--title "$APP_NAME v${{ needs.prepare.outputs.app_version }}" --generate-notes \
dist/$APP_NAME-$APP_VERSION-linux.tar.xz dist/$APP_NAME-$APP_VERSION-mac.zip dist/$APP_NAME-$APP_VERSION-win.exe.zip