Skip to content

Commit 510e4ce

Browse files
committed
feat: set-version at publish task
1 parent ee00567 commit 510e4ce

File tree

70 files changed

+197
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+197
-59
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Download Cache
2+
description: Download and restore the Cache artifact (check ../upload-cache)
3+
inputs:
4+
artifactName:
5+
description: Name of the artifact on which the cache is published
6+
default: cache-dir
7+
required: false
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
13+
with:
14+
name: ${{ inputs.artifactName }}
15+
path: '.'
16+
- run: unzip -q -n ${{ inputs.artifactName }}.zip
17+
shell: bash
18+
- run: rm -f ${{ inputs.artifactName }}.zip
19+
shell: bash
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Upload Cache
2+
description: Upload a Cache artifact
3+
inputs:
4+
artifactName:
5+
description: Name of the artifact on which the cache is published
6+
default: cache-dir
7+
required: false
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- run: zip -q -r ${{ inputs.artifactName }}.zip . -i ".cache/*" -x "*/node_modules/*"
13+
shell: bash
14+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
15+
with:
16+
name: ${{ inputs.artifactName }}
17+
path: ${{ inputs.artifactName }}.zip
18+
- run: rm -f ${{ inputs.artifactName }}.zip
19+
shell: bash

.github/workflows/it-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
artifactName: ${{ inputs.ref && format('dist-{0}', inputs.ref) || 'dist' }}
4747
- uses: ./tools/github-actions/setup
4848
timeout-minutes: 30
49+
- if: ${{env.NX_SKIP_REMOTE_CACHE == 'true'}}
50+
uses: ./.github/actions/download-cache
51+
continue-on-error: true
4952
- name: Setup verdaccio once for all tests
5053
id: setup-verdaccio
5154
run: |

.github/workflows/main.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
runs-on: ubuntu-latest
5353
needs: [yarn_lock_check]
5454
env:
55-
NX_SKIP_NX_CACHE: ${{ vars.NX_SKIP_NX_CACHE == 'true' || github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && !endsWith(github.ref, '-next') }}
56-
NX_SKIP_REMOTE_CACHE: ${{ vars.NX_SKIP_REMOTE_CACHE || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
55+
NX_SKIP_NX_CACHE: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
56+
NX_SKIP_REMOTE_CACHE: ${{ vars.NX_SKIP_REMOTE_CACHE || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
5757
NODE_COMPILE_CACHE: ~/.cache/node-compilation
5858
steps:
5959
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -72,6 +72,9 @@ jobs:
7272
${{ runner.os }}-node-compile
7373
- run: yarn build
7474
- uses: ./tools/github-actions/upload-build-output
75+
- if: ${{env.NX_SKIP_REMOTE_CACHE == 'true'}}
76+
uses: ./.github/actions/upload-cache
77+
continue-on-error: true
7578

7679
version:
7780
permissions:
@@ -111,17 +114,17 @@ jobs:
111114
needs: [yarn_lock_check]
112115
with:
113116
affected: ${{ github.event_name == 'pull_request' }}
114-
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' || github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && !endsWith(github.ref, '-next') }}
115-
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
117+
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
118+
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
116119

117120
it-tests:
118121
uses: ./.github/workflows/it-tests.yml
119122
secrets:
120123
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
121124
needs: [yarn_lock_check, build]
122125
with:
123-
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' || github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && !endsWith(github.ref, '-next') }}
124-
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
126+
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
127+
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
125128

126129
e2e-tests:
127130
permissions:
@@ -131,8 +134,8 @@ jobs:
131134
uses: ./.github/workflows/e2e-tests.yml
132135
needs: [yarn_lock_check, build]
133136
with:
134-
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' || github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && !endsWith(github.ref, '-next') }}
135-
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
137+
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
138+
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
136139

137140
publish-packages:
138141
uses: ./.github/workflows/publish.yml
@@ -147,8 +150,8 @@ jobs:
147150
version: ${{ needs.version.outputs.nextVersionTag }}
148151
prerelease: ${{ needs.version.outputs.isPreRelease == 'true' }}
149152
isPullRequest: false
150-
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' || github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && !endsWith(github.ref, '-next') }}
151-
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' }}
153+
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
154+
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) }}
152155

153156
documentation-main:
154157
secrets: inherit
@@ -158,7 +161,7 @@ jobs:
158161
with:
159162
version: ${{ needs.version.outputs.nextVersionTag }}
160163
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
161-
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' }}
164+
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) }}
162165
documentation-pr:
163166
secrets: inherit
164167
needs: [yarn_lock_check, version]
@@ -168,4 +171,4 @@ jobs:
168171
version: ${{ needs.version.outputs.nextVersionTag }}
169172
shouldDeploy: false
170173
skipNxCache: ${{ vars.NX_SKIP_NX_CACHE == 'true' }}
171-
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}
174+
skipNxRemoteCache: ${{ vars.NX_SKIP_REMOTE_CACHE == 'true'|| (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')) || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'skipRemoteCache')) }}

.github/workflows/publish.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,22 @@ jobs:
7272
fetch-depth: 2
7373
ref: ${{ inputs.gitRef }}
7474
- uses: ./tools/github-actions/download-build-output
75+
- if: ${{env.NX_SKIP_REMOTE_CACHE == 'true'}}
76+
uses: ./.github/actions/download-cache
77+
continue-on-error: true
7578
- uses: ./tools/github-actions/setup
7679
timeout-minutes: 30
7780
with:
7881
#TODO Remove when migrate to Node 24
7982
npm-version: '11.5'
80-
- run: yarn set:version ${{ inputs.version }}
8183
- name: Get tag name
8284
id: get-npm-tag
8385
uses: ./tools/github-actions/get-npm-tag
8486
with:
8587
is-prerelease: ${{ inputs.prerelease }}
8688
version: ${{ inputs.version }}
8789
- name: Publish
88-
run: yarn run publish --tag=${{ inputs.isPullRequest && 'pr' || steps.get-npm-tag.outputs.tag }} ${{ inputs.isPullRequest && '--userconfig=./.npmrc.pr' || ''}}
90+
run: yarn run publish --set-version=${{ inputs.version }} --tag=${{ inputs.isPullRequest && 'pr' || steps.get-npm-tag.outputs.tag }} ${{ inputs.isPullRequest && '--userconfig=./.npmrc.pr' || ''}}
8991
env:
9092
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9193
AZURE_AUTH_TOKEN: ${{ secrets.AZURE_AUTH_TOKEN }}
@@ -103,6 +105,9 @@ jobs:
103105
with:
104106
fetch-depth: 2
105107
- uses: ./tools/github-actions/download-build-output
108+
- if: ${{env.NX_SKIP_REMOTE_CACHE == 'true'}}
109+
uses: ./.github/actions/download-cache
110+
continue-on-error: true
106111
- uses: ./tools/github-actions/setup
107112
timeout-minutes: 30
108113
- run: yarn set:version ${{ inputs.version }}
@@ -137,12 +142,14 @@ jobs:
137142
with:
138143
fetch-depth: 2
139144
- uses: ./tools/github-actions/download-build-output
145+
- if: ${{env.NX_SKIP_REMOTE_CACHE == 'true'}}
146+
uses: ./.github/actions/download-cache
147+
continue-on-error: true
140148
- uses: ./tools/github-actions/setup
141149
timeout-minutes: 30
142-
- run: yarn set:version ${{ inputs.version }}
143150
- name: Publish Extensions
144151
if: '!inputs.prerelease'
145-
run: yarn run publish:extensions
152+
run: yarn run publish:extensions --set-version=${{ inputs.version }}
146153
env:
147154
NX_BASE: HEAD~1
148155
VSCE_PAT: ${{ secrets.AZURE_VSC_EXT_TOKEN }}

apps/chrome-devtools/project.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@
161161
"{projectRoot}/src/options.html"
162162
]
163163
},
164+
"set-version": {},
165+
"prepare-publish": {},
164166
"publish-extension": {
165167
"executor": "nx:run-script",
166168
"options": {

apps/vscode-extension/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
"lint": {},
2929
"test": {},
30+
"set-version": {},
3031
"prepare-publish": {
3132
"options": {
3233
"commands": [

nx.json

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,23 @@
1717
}
1818
},
1919
"namedInputs": {
20+
"sharedGlobals": [
21+
"{workspaceRoot}/yarn.lock",
22+
"{workspaceRoot}/tsconfig.base.json",
23+
"{workspaceRoot}/nx.json",
24+
"{workspaceRoot}/.nxignore",
25+
{
26+
"runtime": "node -p 'process.versions.node.split(\".\")[0]'"
27+
}
28+
],
2029
"project": [
2130
"{projectRoot}/package.json",
2231
"{projectRoot}/project.json"
2332
],
2433
"base": [
2534
"project",
26-
"{workspaceRoot}/yarn.lock",
27-
"{workspaceRoot}/tsconfig.base.json",
35+
"sharedGlobals",
2836
"{workspaceRoot}/tsconfig.build.json",
29-
"{workspaceRoot}/nx.json",
30-
"{workspaceRoot}/.nxignore",
3137
"{workspaceRoot}/tools/@o3r/build-helpers/scripts/*.mjs"
3238
],
3339
"source": [
@@ -267,6 +273,35 @@
267273
"outputs": [],
268274
"inputs": [
269275
"{projectRoot}/dist"
276+
],
277+
"dependsOn": [
278+
"prepare-publish",
279+
{
280+
"projects": "self",
281+
"target": "set-version",
282+
"params": "forward"
283+
}
284+
]
285+
},
286+
"set-version": {
287+
"cache": false,
288+
"executor": "nx:run-commands",
289+
"options": {
290+
"cwd": "{workspaceRoot}",
291+
"command": "O3R_SET_PUBLIC='{args.set-public}' yarn o3r-set-version {args.set-version} --placeholder=0.0.0-placeholder --include='{projectRoot}/dist/package.json' --include='{projectRoot}/dist/manifest.json'",
292+
"forwardAllArgs": false
293+
},
294+
"inputs": [
295+
"{projectRoot}/dist/package.json",
296+
"{projectRoot}/dist/manifest.json"
297+
],
298+
"outputs": [
299+
"{projectRoot}/dist/package.json",
300+
"{projectRoot}/dist/manifest.json"
301+
],
302+
"dependsOn": [
303+
"build",
304+
"prepare-publish"
270305
]
271306
},
272307
"prepare-publish": {
@@ -296,7 +331,15 @@
296331
]
297332
},
298333
"publish-extension": {
299-
"cache": false
334+
"cache": false,
335+
"dependsOn": [
336+
"prepare-publish",
337+
{
338+
"projects": "self",
339+
"target": "set-version",
340+
"params": "forward"
341+
}
342+
]
300343
},
301344
"build": {
302345
"dependsOn": [
@@ -644,7 +687,7 @@
644687
"libsDir": "packages",
645688
"appsDir": "apps"
646689
},
647-
"useDaemonProcess": false,
690+
"useDaemonProcess": true,
648691
"cacheDirectory": ".cache/nx",
649692
"nxCloudId": "63e6951e043da20dd8321aec"
650693
}

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"nx": "nx",
88
"ng": "yarn nx",
99
"amaterasu": "node packages/@ama-terasu/cli/dist/src/cli/ama.js",
10-
"get:cpus-number": "node -e 'process.stdout.write(`${process.env.NX_PARALLEL || Math.max(require(\"os\").cpus().length - 1, 2)}`);'",
11-
"print:nx-parallel": "node -e \"process.stdout.write(`NX_PARALLEL=$(yarn get:cpus-number)`)\"",
12-
"get:current-dir": "node -e 'process.stdout.write(process.cwd());'",
10+
"get:cpus-number": "node -p '`${process.env.NX_PARALLEL || Math.max(require(\"os\").cpus().length - 1, 2)}`'",
11+
"print:nx-parallel": "node -p \"`NX_PARALLEL=$(yarn get:cpus-number)`\"",
12+
"get:current-dir": "node -p 'process.cwd()'",
1313
"create:scope": "yarn create-monorepo-scope",
1414
"build": "yarn nx run-many --target=$(yarn get-build-targets)",
1515
"build:affected": "yarn nx affected --target=$(yarn get-build-targets) --output-style stream",
1616
"build:ts": "yarn nx run-many --target=build",
1717
"build:tools": "yarn nx run-many --target=build --projects=eslint-plugin,workspace,test-helpers",
1818
"build:lint": "yarn nx run-many --target=build --projects=eslint-plugin",
1919
"build:swagger-gen": "yarn nx run-many --target=build-swagger",
20-
"publish": "yarn nx run-many --target=prepare-publish --exclude-task-dependencies && yarn nx run-many --target=publish --exclude=tag:private",
21-
"publish:extensions": "yarn nx run-many --target=prepare-publish --exclude-task-dependencies && yarn nx run-many --target=publish-extension",
20+
"publish": "yarn nx run-many --target=publish --exclude=tag:private",
21+
"publish:extensions": "yarn nx run-many --target=publish-extension",
2222
"publish:extensions:affected": "yarn nx affected --target=publish-extension",
2323
"package-github-actions:affected": "yarn nx affected --target=package-github-action",
2424
"lint": "yarn nx run-many --target=lint",
@@ -30,7 +30,7 @@
3030
"postinstall": "husky && yarn build:lint && yarn harmonize:version && yarn update-yarn-sdks && yarn install --mode=skip-build",
3131
"update-yarn-sdks": "node -e \"'pnp' !== '$(yarn config get nodeLinker)' || process.exit(1)\" || yarn sdks",
3232
"clear": "rimraf -g './{packages,tools,apps}/{@*/,}{amaterasu/,}*/{dist,build,dist-*}/'",
33-
"set:version": "yarn o3r-set-version --placeholder 0.0.0-placeholder --include '{apps,packages,tools}/**/dist/{package,manifest}.json'",
33+
"set:version": "yarn nx run-many --target=set-version",
3434
"harmonize:version": "eslint --quiet --fix $(git ls-files \":(glob)**/package.json\" .yarnrc.yml)",
3535
"doc:packages": "yarn nx run-many --target=documentation",
3636
"doc:root": "yarn prepare-doc-root-menu-template && yarn update-doc-summary ./docs && yarn compodoc",
@@ -42,8 +42,8 @@
4242
"verdaccio:start-persistent": "docker run -d -it --rm --name verdaccio -p 4873:4873 -v \"$(yarn get:current-dir)/.verdaccio/conf\":/verdaccio/conf -v \"$(yarn get:current-dir)/.verdaccio/storage\":/verdaccio/storage:z verdaccio/verdaccio",
4343
"verdaccio:clean": "rimraf -g \".verdaccio/storage/@{o3r,ama-sdk,ama-terasu,ama-mfe,ama-styling,o3r-training,ama-mcp}\"",
4444
"verdaccio:login": "yarn cpy .verdaccio/conf/.npmrc .verdaccio/conf --rename=.npmrc-logged --flat --dot && npx --yes npm-cli-login -u verdaccio -p verdaccio -e [email protected] -r http://127.0.0.1:4873 --config-path \".verdaccio/conf/.npmrc-logged\"",
45-
"verdaccio:prepare-publish": "yarn verdaccio:clean && yarn set:version 999.0.$(node -e 'process.stdout.write(String(Date.now()))') --include \"!**/!(dist)/package.json\" --include !package.json && yarn verdaccio:login && replace-in-files --regex=\"private(.*)true\" --replacement=private\\$1false '**/dist/package.json' && yarn nx run-many --target=prepare-publish --exclude-task-dependencies",
46-
"verdaccio:publish": "yarn run verdaccio:prepare-publish && yarn nx run-many --target=publish --nx-bail --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873 --@o3r-training:registry=http://127.0.0.1:4873 --@ama-mfe:registry=http://127.0.0.1:4873 --@ama-styling:registry=http://127.0.0.1:4873 --@ama-mcp:registry=http://127.0.0.1:4873",
45+
"verdaccio:prepare-publish": "yarn verdaccio:clean && yarn verdaccio:login",
46+
"verdaccio:publish": "yarn run verdaccio:prepare-publish && yarn nx run-many --target=publish --nx-bail --set-public --set-version=999.0.$(node -p 'String(Date.now())') --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873 --@o3r-training:registry=http://127.0.0.1:4873 --@ama-mfe:registry=http://127.0.0.1:4873 --@ama-styling:registry=http://127.0.0.1:4873 --@ama-mcp:registry=http://127.0.0.1:4873",
4747
"verdaccio:stop": "docker container stop $(docker ps -a -q --filter=\"name=verdaccio\")",
4848
"verdaccio:all": "yarn verdaccio:stop && yarn verdaccio:start && yarn verdaccio:publish",
4949
"watch:vscode-extension": "yarn nx run vscode-extension:compile:watch",
@@ -267,7 +267,6 @@
267267
"postcss-scss": "~4.0.9",
268268
"prism-themes": "^1.9.0",
269269
"prismjs": "^1.30.0",
270-
"replace-in-files-cli": "^3.0.0",
271270
"rimraf": "^6.0.1",
272271
"sass": "~1.93.0",
273272
"sass-loader": "^16.0.0",

packages/@ama-mcp/angular/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test": {},
2020
"lint": {},
2121
"prepare-publish": {},
22+
"set-version": {},
2223
"publish": {}
2324
},
2425
"tags": []

0 commit comments

Comments
 (0)