@@ -17,31 +17,90 @@ concurrency:
17
17
cancel-in-progress : true
18
18
19
19
env :
20
+ APP_CARGO_TOML : src-tauri/Cargo.toml
20
21
CN_APP_SLUG : ${{ github.event.inputs.app-slug || 'quantum' }}
21
22
22
23
jobs :
23
24
draft :
24
25
runs-on : ubuntu-latest
25
-
26
+ outputs :
27
+ tag_name : ${{ steps.read_version.outputs.value }}
28
+ needs_release : ${{ steps.create_tag.outputs.tag_existed != 'true' }}
29
+ permissions :
30
+ contents : write
26
31
steps :
27
32
- uses : actions/checkout@v4
28
33
29
- - name : create draft release
34
+ - name : Read version number
35
+ uses : SebRollen/toml-action@v1.0.2
36
+ id : read_version
37
+ with :
38
+ file : ${{ env.APP_CARGO_TOML }}
39
+ field : " package.version"
40
+
41
+ - name : Create tag
42
+ id : create_tag
43
+ uses : actions/github-script@v7
44
+ with :
45
+ script : |
46
+ const tag = "${{ steps.read_version.outputs.value }}";
47
+ const tagRef = `tags/${tag}`;
48
+
49
+ const TAG_EXISTED = "tag_existed";
50
+
51
+ async function main() {
52
+ let tagExisted = true;
53
+
54
+ try {
55
+ await github.rest.git.getRef({
56
+ ref: tagRef,
57
+ owner: context.repo.owner,
58
+ repo: context.repo.repo,
59
+ });
60
+
61
+ tagExisted = true;
62
+ core.notice(`Release skipped as tag '${tag}' already exists. Update the version in '${{ env.APP_CARGO_TOML }}' to perform a release.`);
63
+ } catch (error) {
64
+ if ("status" in error && error.status === 404) tagExisted = false;
65
+ else throw error;
66
+ }
67
+
68
+ core.setOutput(TAG_EXISTED, tagExisted);
69
+
70
+ if (!tagExisted)
71
+ await github.rest.git.createRef({
72
+ ref: `refs/${tagRef}`,
73
+ owner: context.repo.owner,
74
+ repo: context.repo.repo,
75
+ sha: context.sha,
76
+ });
77
+ }
78
+
79
+ main();
80
+
81
+ - name : Create draft release
82
+ if : ${{ steps.create_tag.outputs.tag_existed != 'true' }}
30
83
uses : crabnebula-dev/cloud-release@v0.1.0
31
84
with :
32
- command : release draft ${{ env.CN_APP_SLUG }} --framework tauri
85
+ command : release draft ${{ vars.CN_APP_ID }} "${{ steps.read_version.outputs.value }}" --framework tauri
33
86
api-key : ${{ secrets.CN_API_KEY }}
34
87
35
88
build :
36
89
needs : draft
37
-
90
+ runs-on : ${{ matrix.os }}
91
+ if : ${{ needs.draft.outputs.needs_release == 'true' }}
38
92
strategy :
39
93
fail-fast : false
40
94
matrix :
41
- os : [ubuntu-latest, macos-latest, windows-latest]
42
-
43
- runs-on : ${{ matrix.os }}
44
-
95
+ settings :
96
+ - host : macos-latest
97
+ target : x86_64-apple-darwin
98
+ - host : macos-latest
99
+ target : aarch64-apple-darwin
100
+ - host : windows-latest
101
+ target : x86_64-pc-windows-msvc
102
+ - host : ubuntu-latest
103
+ target : x86_64-unknown-linux-gnu
45
104
steps :
46
105
- uses : actions/checkout@v4
47
106
- name : Install pnpm
@@ -59,35 +118,33 @@ jobs:
59
118
cache : false
60
119
61
120
- name : install Linux dependencies
62
- if : matrix.os == 'ubuntu-latest'
121
+ if : matrix.host == 'ubuntu-latest'
63
122
run : |
64
123
sudo apt-get update
65
124
sudo apt-get install -y libwebkit2gtk-4.0-dev webkit2gtk-4.1
66
125
67
126
- name : build tauri app
68
127
run : |
69
128
pnpm install
70
- pnpm run tauri build
129
+ pnpm run tauri build --ci --target ${{ matrix.settings.target }}
71
130
env :
72
131
TAURI_SIGNING_PRIVATE_KEY : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
73
132
TAURI_SIGNING_PRIVATE_KEY_PASSWORD : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
74
133
75
134
- name : upload assets
76
135
uses : crabnebula-dev/cloud-release@v0.1.0
77
136
with :
78
- command : release upload ${{ env.CN_APP_SLUG }} --framework tauri
137
+ command : release upload ${{ env.CN_APP_SLUG }} "${{ steps.read_version.outputs.value }}" --framework tauri
79
138
api-key : ${{ secrets.CN_API_KEY }}
80
139
81
140
publish :
82
- needs : build
83
-
141
+ needs : [draft, build]
84
142
runs-on : ubuntu-latest
85
-
86
143
steps :
87
144
- uses : actions/checkout@v4
88
145
89
146
- name : publish release
90
147
uses : crabnebula-dev/cloud-release@v0.1.0
91
148
with :
92
- command : release publish ${{ env.CN_APP_SLUG }} --framework tauri
149
+ command : release publish ${{ env.CN_APP_SLUG }} "${{ needs.draft.outputs.tag_name }}" --framework tauri
93
150
api-key : ${{ secrets.CN_API_KEY }}
0 commit comments