Skip to content

Commit a39e8ba

Browse files
committed
ci(release): add proper version to npm dist fragments
Refs #3687
1 parent afde55d commit a39e8ba

File tree

3 files changed

+77
-64
lines changed

3 files changed

+77
-64
lines changed

.github/workflows/docker-build-push.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,33 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v3
19+
- uses: actions/checkout@v3
2120
with:
22-
fetch-depth: 0
23-
persist-credentials: false
24-
submodules: true
2521
ref: next
2622

27-
- name: Setup Node.js
28-
uses: actions/setup-node@v3
23+
- name: Download build artifact
24+
uses: actions/github-script@v6
2925
with:
30-
node-version: 16.16
31-
registry-url: https://npm.pkg.github.com/
32-
scope: "@swagger-api"
33-
34-
- name: Install dependencies
35-
run: npm ci
36-
env:
37-
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
38-
39-
- name: Build App artifacts
40-
run: npm run build:app
26+
script: |
27+
const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
run_id: context.payload.workflow_run.id,
31+
});
32+
const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
33+
return artifact.name == "build"
34+
})[0];
35+
const download = await github.rest.actions.downloadArtifact({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
artifact_id: matchArtifact.id,
39+
archive_format: 'zip',
40+
});
41+
const fs = require('fs');
42+
fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
43+
- run: |
44+
mkdir build
45+
unzip build.zip -d build
4146
4247
- name: Set up QEMU
4348
uses: docker/setup-qemu-action@v2

.github/workflows/release.yml

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ jobs:
2424
registry-url: https://npm.pkg.github.com/
2525
scope: "@swagger-api"
2626

27-
- name: Semantic Release
28-
id: semantic
27+
- name: Determine the next release version
2928
uses: cycjimmy/semantic-release-action@v3
3029
with:
3130
dry_run: true
@@ -37,48 +36,57 @@ jobs:
3736
NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
3837
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
3938

40-
- name: Next version
39+
- name: Nothing to release
40+
if: ${{ env.NEXT_RELEASE_VERSION == '' }}
41+
uses: actions/github-script@v6
42+
with:
43+
script: |
44+
core.setFailed('Nothing to release')
45+
46+
- name: Install dependencies
47+
run: npm ci
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
50+
51+
- name: Prepare for the Release
52+
env:
53+
REACT_APP_VERSION: ${{ env.NEXT_RELEASE_VERSION }}
54+
run: |
55+
npm run lint
56+
npm run test
57+
npm run build:app
58+
npm run cy:ci
59+
npm run build:bundle:esm
60+
npm run build:bundle:umd
61+
62+
- name: Semantic Release
63+
id: semantic
64+
uses: cycjimmy/semantic-release-action@v3
65+
with:
66+
dry_run: false
67+
extra_plugins: |
68+
@semantic-release/git
4169
env:
42-
NEXT_RELEASE_VERSION: ${{ env.NEXT_RELEASE_VERSION }}
43-
run: echo $NEXT_RELEASE_VERSION
70+
GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
71+
NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
72+
NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
73+
74+
- name: Release failed
75+
if: steps.semantic.outputs.new_release_published == 'false'
76+
uses: actions/github-script@v6
77+
with:
78+
script: |
79+
core.setFailed('Release failed')
4480
45-
# - name: Install dependencies
46-
# run: npm ci
47-
# env:
48-
# NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
49-
#
50-
# - name: Prepare for the Release
51-
# run: |
52-
# npm run lint
53-
# npm run test
54-
# npm run build:app
55-
# npm run cy:ci
56-
# npm run build:bundle:esm
57-
# npm run build:bundle:umd
58-
#
59-
# - name: Semantic Release
60-
# id: semantic
61-
# uses: cycjimmy/semantic-release-action@v3
62-
# with:
63-
# dry_run: false
64-
# extra_plugins: |
65-
# @semantic-release/git
66-
# env:
67-
# GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
68-
# NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
69-
# NODE_AUTH_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }}
70-
#
71-
# - name: Release published
72-
# if: steps.semantic.outputs.new_release_published == 'true'
73-
# run: |
74-
# echo ${{ steps.semantic.outputs.new_release_version }}
75-
# echo ${{ steps.semantic.outputs.new_release_major_version }}
76-
# echo ${{ steps.semantic.outputs.new_release_minor_version }}
77-
# echo ${{ steps.semantic.outputs.new_release_patch_version }}
78-
#
79-
# - name: Release failed
80-
# if: steps.semantic.outputs.new_release_published == 'false'
81-
# uses: actions/github-script@v6
82-
# with:
83-
# script: |
84-
# core.setFailed('Release failed')
81+
- name: Release published
82+
run: |
83+
echo ${{ steps.semantic.outputs.new_release_version }}
84+
echo ${{ steps.semantic.outputs.new_release_major_version }}
85+
echo ${{ steps.semantic.outputs.new_release_minor_version }}
86+
echo ${{ steps.semantic.outputs.new_release_patch_version }}
87+
88+
- name: Upload build artifacts
89+
uses: actions/upload-artifact@v3
90+
with:
91+
name: build
92+
path: ./build

0 commit comments

Comments
 (0)