Skip to content

Commit b876389

Browse files
authored
bug(npm): Attempt to fix issue with Trusted Publishers when using reusable workflows (#6446)
* Added a new publish-npm.yml inside workflows * Delete action.yml * Restructure npm publish action * Add id-token write * Update publish-npm.yml * Drive releases through a single orchestrator workflow Drive releases through a single orchestrator workflow that: Keeps the nightly cron Offers manual dispatch inputs for dev/nightly/production Passes the production tag/base down to release-production.yml Without that orchestrator, the nightly job will stop running and dev/prod releases can’t be dispatched from the GitHub UI. Let me know if you’d like me to wire the orchestrator back up (or revert the individual workflow_dispatch blocks) so the previous scheduling behavior continues uninterrupted. * Fix prettier issue
1 parent 6b01357 commit b876389

File tree

6 files changed

+135
-83
lines changed

6 files changed

+135
-83
lines changed

.github/workflows/actions/publish-npm/action.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/publish-npm.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: 'Release'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'The type of version to release.'
8+
required: true
9+
type: string
10+
tag:
11+
description: 'The tag to publish to on NPM.'
12+
required: true
13+
type: string
14+
node-version:
15+
description: 'Node.js version to use when publishing.'
16+
required: false
17+
type: string
18+
default: '20'
19+
registry-url:
20+
description: 'Registry URL used for npm publish.'
21+
required: false
22+
type: string
23+
default: 'https://registry.npmjs.org'
24+
scope:
25+
description: 'npm scope that should use the trusted publisher auth.'
26+
required: false
27+
type: string
28+
default: '@stencil'
29+
30+
permissions:
31+
contents: read
32+
id-token: write
33+
34+
jobs:
35+
publish:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: 📥 Checkout Code
39+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
40+
41+
- name: 🕸️ Get Core Dependencies
42+
uses: ./.github/workflows/actions/get-core-dependencies
43+
44+
- name: 🟢 Configure Node for Publish
45+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
46+
with:
47+
node-version: ${{ inputs.node-version }}
48+
registry-url: ${{ inputs.registry-url }}
49+
scope: ${{ inputs.scope }}
50+
51+
- name: 🔄 Ensure Latest npm
52+
run: npm install -g npm@latest
53+
shell: bash
54+
55+
- name: 📥 Download Build Archive
56+
uses: ./.github/workflows/actions/download-archive
57+
with:
58+
name: stencil-core
59+
path: .
60+
filename: stencil-core-build.zip
61+
62+
- name: 🏷️ Set Version
63+
run: npm version --no-git-tag-version ${{ inputs.version }}
64+
shell: bash
65+
66+
- name: 🚀 Publish to NPM
67+
run: npm publish --tag ${{ inputs.tag }} --provenance
68+
shell: bash

.github/workflows/release-dev.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: 'Stencil Dev Release'
22

33
on:
4-
workflow_dispatch:
5-
# Make this a reusable workflow, no value needed
6-
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
74
workflow_call:
85
outputs:
96
dev-version:
@@ -58,15 +55,7 @@ jobs:
5855
release-stencil-dev-build:
5956
name: 🚀 Publish Dev Build
6057
needs: [get-dev-version, build_core]
61-
runs-on: ubuntu-22.04
62-
permissions:
63-
contents: read
64-
id-token: write
65-
steps:
66-
- name: 📥 Checkout Code
67-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
68-
- name: 📦 Publish to NPM
69-
uses: ./.github/workflows/actions/publish-npm
70-
with:
71-
tag: dev
72-
version: ${{ needs.get-dev-version.outputs.dev-version }}
58+
uses: ./.github/workflows/publish-npm.yml
59+
with:
60+
tag: dev
61+
version: ${{ needs.get-dev-version.outputs.dev-version }}

.github/workflows/release-nightly.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
name: 'Stencil Nightly Release'
22

33
on:
4-
schedule:
5-
# Run every Monday-Friday at 5:00 AM (UTC) (https://crontab.guru/#00_05_*_*_1-5)
6-
# This is done to have a nightly build ready for the Ionic Framework/Stencil Eval Workflow:
7-
# https://github.com/ionic-team/ionic-framework/blob/main/.github/workflows/stencil-eval.yml
8-
- cron: '00 05 * * 1-5'
9-
workflow_dispatch:
10-
# Allow this workflow to be run on-demand
4+
workflow_call:
115

126
permissions:
137
contents: read
@@ -60,15 +54,7 @@ jobs:
6054
release-stencil-nightly-build:
6155
name: 🚀 Publish Nightly Build
6256
needs: [get-nightly-version, build_core]
63-
runs-on: ubuntu-22.04
64-
permissions:
65-
contents: read
66-
id-token: write
67-
steps:
68-
- name: 📥 Checkout Code
69-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
70-
- name: 🚀 Publish to NPM
71-
uses: ./.github/workflows/actions/publish-npm
72-
with:
73-
tag: nightly
74-
version: ${{ needs.get-nightly-version.outputs.nightly-version }}
57+
uses: ./.github/workflows/publish-npm.yml
58+
with:
59+
tag: nightly
60+
version: ${{ needs.get-nightly-version.outputs.nightly-version }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Stencil Release'
2+
3+
on:
4+
schedule:
5+
# Run every Monday-Friday at 5:00 AM (UTC)
6+
- cron: '00 05 * * 1-5'
7+
workflow_dispatch:
8+
inputs:
9+
release-type:
10+
description: 'Which Stencil release workflow should run?'
11+
required: true
12+
type: choice
13+
default: nightly
14+
options:
15+
- dev
16+
- nightly
17+
- production
18+
tag:
19+
description: 'npm tag for production releases.'
20+
required: false
21+
type: choice
22+
default: latest
23+
options:
24+
- dev
25+
- latest
26+
- use_pkg_json_version
27+
base:
28+
description: 'Base branch for production releases.'
29+
required: false
30+
type: choice
31+
default: main
32+
options:
33+
- main
34+
- v3-maintenance
35+
36+
permissions:
37+
contents: read
38+
id-token: write
39+
40+
jobs:
41+
run-nightly:
42+
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.release-type == 'nightly') }}
43+
uses: ./.github/workflows/release-nightly.yml
44+
secrets: inherit
45+
46+
run-dev:
47+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release-type == 'dev' }}
48+
uses: ./.github/workflows/release-dev.yml
49+
secrets: inherit
50+
51+
run-production:
52+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release-type == 'production' }}
53+
uses: ./.github/workflows/release-production.yml
54+
secrets: inherit
55+
with:
56+
tag: ${{ inputs.tag }}
57+
base: ${{ inputs.base }}

.github/workflows/release-production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 'Stencil Production Release'
22
on:
3-
workflow_dispatch:
3+
workflow_call:
44
inputs:
55
tag:
66
required: false

0 commit comments

Comments
 (0)