-
-
Notifications
You must be signed in to change notification settings - Fork 140
164 lines (143 loc) · 5.24 KB
/
release.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
name: "Publish Release"
on:
push:
tags:
- "v*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
run-tests-and-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- run: npm clean-install
- run: npm run lint
- run: npm run test
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
needs: run-tests-and-linter
outputs:
release_id: ${{ steps.create-release.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Get version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Create release
id: create-release
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const changelogContent = fs.readFileSync('changelog.md', 'utf-8');
const regex = new RegExp( `(?<=\\[${process.env.PACKAGE_VERSION}\\]\\s)([\\s\\S]*?)(?=\\s## \\[)`, 'g');
const releaseNotes = changelogContent.match(regex)?.[0].trim() || '';
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${process.env.PACKAGE_VERSION}`,
name: `Seelen UI v${process.env.PACKAGE_VERSION}`,
body: releaseNotes + "\n",
generate_release_notes: true,
draft: true,
prerelease: false,
});
return data.id;
build-installers:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "windows-latest"
args: ""
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install winget
uses: Cyberboss/install-winget@v1
- name: Install MSIX dependencies
if: matrix.platform == 'windows-latest'
shell: powershell
run: |
winget install --id Microsoft.DotNet.AspNetCore.8 --accept-package-agreements --accept-source-agreements --force
winget install --id Microsoft.DotNet.DesktopRuntime.8 --accept-package-agreements --accept-source-agreements --force
winget install --id MarcinOtorowski.MSIXHero --accept-package-agreements --accept-source-agreements --force
- name: Install frontend dependencies
run: npm install
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
args: ${{ matrix.args }}
- name: Bundle MSIX
run: npx ts-node scripts/bundle.msix.ts
- name: Add msix to release
uses: "actions/github-script@v7"
env:
releaseId: ${{ needs.create-release.outputs.release_id }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const fs = require('fs');
const packageJson = require('./package.json');
const packageVersion = packageJson.version + '.0';
await github.rest.repos.uploadReleaseAsset({
name: `Seelen.SeelenUI_${packageVersion}_x64__p6yyn03m1894e.msix`,
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.releaseId,
data: fs.readFileSync(`./target/release/bundle/msix/Seelen.SeelenUI_${packageVersion}_x64__p6yyn03m1894e.msix`)
});
publish-release:
needs: [build-installers, create-release]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Publish release
uses: actions/github-script@v7
env:
releaseId: ${{ needs.create-release.outputs.release_id }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
const result = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.releaseId,
});
result.data.forEach(async (asset) => {
if (asset.name.endsWith('.sig')) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id,
});
}
});
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.releaseId,
draft: false,
});