forked from DwarfTelescopeUsers/dwarfii-stellarium-goto
-
Notifications
You must be signed in to change notification settings - Fork 5
179 lines (155 loc) · 5.72 KB
/
build.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: 'build'
on:
workflow_dispatch:
jobs:
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [macos-13, macOS-latest, ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: install Rust stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: '1.78'
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: Get version number from package.json
id: get_version
run: |
node -e "console.log(require('./package.json').version)" > version.txt
echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV
shell: bash
- name: Install dependencies
run: |
npm install
npm install -g pkg
- name: Verify @tauri-apps/api and cli version
run: |
npm list @tauri-apps/api
npm list @tauri-apps/cli
- name: Build
if: matrix.platform == 'ubuntu-20.04'
run: |
npm run build
npm run prepare:dist
zip -r Dwarfium.zip Dwarfium
- name: Build Windows
if: matrix.platform == 'windows-latest'
run: |
npm run build
npm run prepare:dist
powershell Compress-Archive -Path Dwarfium -DestinationPath Dwarfium-Win.zip
- name: Create artifact Dwarfium
if: matrix.platform == 'ubuntu-20.04'
uses: actions/upload-artifact@v4
with:
name: Dwarfium-${{ env.VERSION }}
path: Dwarfium.zip
- name: Create artifact Dwarfium Windows
if: matrix.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: Dwarfium-Win-${{ env.VERSION }}
path: Dwarfium-Win.zip
# Download the artifact for subsequent use
- name: Download artifact Dwarfium Windows
if: matrix.platform == 'windows-latest'
uses: actions/download-artifact@v4
with:
name: Dwarfium-Win-${{ env.VERSION }}
path: ./artifacts
- name: install frontend dependencies
run: npm install
- uses: tauri-apps/tauri-action@v0
id: tauri_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
CI: false
with:
tagName: app-v${{ env.VERSION }}
releaseName: 'v${{ env.VERSION }}-DesktopAPP'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: false
prerelease: false
includeUpdaterJson: true
updaterJsonKeepUniversal: false
- name: Release with ncipollo/release-action
if: matrix.platform == 'ubuntu-20.04'
id: release
uses: ncipollo/release-action@v1
with:
artifacts: Dwarfium.zip
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
skipIfReleaseExists: true
tag: v${{ env.VERSION }}
# Add Windows artifacts to the existing release
- name: Add Windows Artifacts
if: matrix.platform == 'windows-latest'
uses: actions/github-script@v6
with:
script: |
const releaseTag = `v${process.env.VERSION}`;
const path = require('path');
const artifactPath = path.join('./artifacts', 'Dwarfium-Win.zip');
// Get the release by tag
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: releaseTag
});
// Upload release asset
const fs = require('fs');
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
name: 'Dwarfium-Win.zip',
data: await fs.readFileSync(artifactPath),
});
update-gist:
runs-on: ubuntu-latest
needs: [publish-tauri]
steps:
- name: Get latest release
id: get_latest_release
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const response = await github.repos.listReleases({ owner, repo });
const latestTag = response.data
.filter(release => release.tag_name.startsWith('app-v'))
.map(release => release.tag_name)
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }))
.pop();
return latestTag;
- name: Download latest.json
run: |
latest_release_tag=${{ steps.get_latest_release.outputs.result }}
latest_json_url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${latest_release_tag}/latest.json"
curl -L "$latest_json_url" -o latest.json
- name: Update Gist
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.TOKEN }}
gist_id: ${{ secrets.GIST_ID }}
file_path: latest.json
file_type: text
gist_description: "Updater JSON for the latest release"
gist_file_name: "latest.json"