@@ -47,12 +47,13 @@ jobs:
4747
4848 - name : Create tag
4949 id : create_tag
50- if : ${{ steps.create_tag.outputs.tag_existed != 'true' }}
5150 uses : actions/github-script@v7
5251 with :
5352 script : |
54- const tag = "cap-v${{ steps.read_version.outputs.value }}";
53+ const version = "${{ steps.read_version.outputs.value }}";
54+ const tag = `cap-v${version}`;
5555 const tagRef = `tags/${tag}`;
56+ const appCargoToml = "${{ env.APP_CARGO_TOML }}";
5657
5758 const TAG_EXISTED = "tag_existed";
5859 const TAG_NAME = "tag_name";
@@ -69,25 +70,30 @@ jobs:
6970 repo: context.repo.repo,
7071 });
7172
72- tagExisted = true;
73- core.notice(`Release skipped as tag '${tag}' already exists. Update the version in '${{ env.APP_CARGO_TOML }}' before starting another release.`);
73+ core.notice(
74+ `Release skipped as tag '${tag}' already exists. Update the version in '${appCargoToml}' before starting another release.`,
75+ );
7476 } catch (error) {
75- if ("status" in error && error.status === 404) tagExisted = false;
76- else throw error;
77+ if ("status" in error && error.status === 404) {
78+ tagExisted = false;
79+ } else {
80+ throw error;
81+ }
7782 }
7883
79- core.setOutput(TAG_EXISTED, tagExisted);
84+ core.setOutput(TAG_EXISTED, tagExisted);
8085
81- if (!tagExisted)
86+ if (!tagExisted) {
8287 await github.rest.git.createRef({
8388 ref: `refs/${tagRef}`,
8489 owner: context.repo.owner,
8590 repo: context.repo.repo,
8691 sha: context.sha,
8792 });
93+ }
8894 }
8995
90- main();
96+ await main();
9197
9298 - name : Create draft CN release
9399 id : create_cn_release
@@ -115,66 +121,65 @@ jobs:
115121 const token = await core.getIDToken("cap-discord-bot");
116122 const cnReleaseId = JSON.parse(`${{ steps.create_cn_release.outputs.stdout }}`).id;
117123
118- const resp = await fetch("https://cap-discord-bot.brendonovich.workers.dev/github-workflow", {
119- method: "POST",
120- body: JSON.stringify({
121- type: "release-ready",
122- tag: "${{ steps.create_tag.outputs.tag_name }}",
123- version: "${{ steps.read_version.outputs.value }}",
124- releaseUrl: "${{ steps.create_gh_release.outputs.url }}",
125- interactionId: "${{ inputs.interactionId }}",
126- cnReleaseId
127- }),
128- headers: {
129- "Content-Type": "application/json",
130- Authorization: `Bearer ${token}`,
131- }
132- });
133-
134- if(resp.status !== 200) throw new Error(await resp.text());
124+ const resp = await fetch(
125+ "https://cap-discord-bot.brendonovich.workers.dev/github-workflow",
126+ {
127+ method: "POST",
128+ body: JSON.stringify({
129+ type: "release-ready",
130+ tag: "${{ steps.create_tag.outputs.tag_name }}",
131+ version: "${{ steps.read_version.outputs.value }}",
132+ releaseUrl: "${{ steps.create_gh_release.outputs.url }}",
133+ interactionId: "${{ inputs.interactionId }}",
134+ cnReleaseId,
135+ }),
136+ headers: {
137+ "Content-Type": "application/json",
138+ Authorization: `Bearer ${token}`,
139+ },
140+ },
141+ );
142+
143+ if (resp.status !== 200) {
144+ throw new Error(await resp.text());
145+ }
135146 }
136147
137- main();
138-
139- build :
140- needs : draft
141- if : ${{
142- needs.draft.outputs.needs_release == 'true' && (
143- matrix.settings.platform != 'windows' ||
144- inputs.windowsTarget == 'all' ||
145- inputs.windowsTarget == matrix.settings.arch
146- )
147- }}
148- permissions :
149- contents : write
150- actions : read
151- strategy :
152- fail-fast : false
153- matrix :
154- settings :
155- - target : x86_64-apple-darwin
156- runner : macos-latest-xlarge
157- platform : macos
158- arch : x64
159- - target : aarch64-apple-darwin
160- runner : macos-latest-xlarge
161- platform : macos
162- arch : arm64
163- - target : x86_64-pc-windows-msvc
164- runner : windows-latest
165- platform : windows
166- arch : x64
167- - target : aarch64-pc-windows-msvc
168- runner : windows-latest
169- platform : windows
170- arch : arm64
171- env :
172- TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
173- TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
174- runs-on : ${{ matrix.settings.runner }}
175- steps :
176- - name : Checkout repository
177- uses : actions/checkout@v4
148+ await main();
149+
150+ build :
151+ needs : draft
152+ if : ${{ needs.draft.outputs.needs_release == 'true' && (matrix.settings.platform != 'windows' || inputs.windowsTarget == 'all' || inputs.windowsTarget == matrix.settings.arch) }}
153+ permissions :
154+ contents : write
155+ actions : read
156+ strategy :
157+ fail-fast : false
158+ matrix :
159+ settings :
160+ - target : x86_64-apple-darwin
161+ runner : macos-latest-xlarge
162+ platform : macos
163+ arch : x64
164+ - target : aarch64-apple-darwin
165+ runner : macos-latest-xlarge
166+ platform : macos
167+ arch : arm64
168+ - target : x86_64-pc-windows-msvc
169+ runner : windows-latest
170+ platform : windows
171+ arch : x64
172+ - target : aarch64-pc-windows-msvc
173+ runner : windows-latest
174+ platform : windows
175+ arch : arm64
176+ env :
177+ TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
178+ TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
179+ runs-on : ${{ matrix.settings.runner }}
180+ steps :
181+ - name : Checkout repository
182+ uses : actions/checkout@v4
178183
179184 - name : Create API Key File
180185 run : echo "${{ secrets.APPLE_API_KEY_FILE }}" > api.p8
@@ -322,22 +327,27 @@ build:
322327 const token = await core.getIDToken("cap-discord-bot");
323328 const cnReleaseId = JSON.parse(`${{ needs.draft.outputs.cn_release_stdout }}`).id;
324329
325- const resp = await fetch("https://cap-discord-bot.brendonovich.workers.dev/github-workflow", {
326- method: "POST",
327- body: JSON.stringify({
328- type: "release-done",
329- interactionId: "${{ inputs.interactionId }}",
330- version: "${{ needs.draft.outputs.version }}",
331- releaseUrl: "${{ needs.draft.outputs.gh_release_url }}",
332- cnReleaseId
333- }),
334- headers: {
335- "Content-Type": "application/json",
336- Authorization: `Bearer ${token}`,
337- }
338- });
339-
340- if(resp.status !== 200) throw new Error(await resp.text());
330+ const resp = await fetch(
331+ "https://cap-discord-bot.brendonovich.workers.dev/github-workflow",
332+ {
333+ method: "POST",
334+ body: JSON.stringify({
335+ type: "release-done",
336+ interactionId: "${{ inputs.interactionId }}",
337+ version: "${{ needs.draft.outputs.version }}",
338+ releaseUrl: "${{ needs.draft.outputs.gh_release_url }}",
339+ cnReleaseId,
340+ }),
341+ headers: {
342+ "Content-Type": "application/json",
343+ Authorization: `Bearer ${token}`,
344+ },
345+ },
346+ );
347+
348+ if (resp.status !== 200) {
349+ throw new Error(await resp.text());
350+ }
341351 }
342352
343- main();
353+ await main();
0 commit comments