Skip to content

Commit 5752cd5

Browse files
committed
Refactor workflows so that only one pushes to npm because OIDC is
currently limited to a single workflow file
1 parent b1f6172 commit 5752cd5

File tree

3 files changed

+77
-51
lines changed

3 files changed

+77
-51
lines changed

.github/workflows/alpha-releases.yml

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,21 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
test:
10-
name: Basic Test
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
- uses: ./.github/actions/setup
15-
- name: build
16-
run: pnpm vite build --mode=development
17-
- name: test
18-
run: pnpm test
9+
tests:
10+
uses: ./.github/workflows/ci-jobs.yml
1911

2012
release:
2113
permissions:
22-
contents: write # to push tag
23-
id-token: write
14+
contents: read # PAT used for push
2415

25-
name: Tag + Release
16+
name: Tag + Push
2617
runs-on: ubuntu-latest
27-
needs: [test]
18+
needs: [ tests ]
2819
steps:
2920
- uses: actions/checkout@v4
30-
- uses: ./.github/actions/setup
3121
with:
32-
node-version: '20'
33-
- name: Update npm
34-
run: npm install -g npm@latest # npm >= 11.5.1 is needed
22+
persist-credentials: false
23+
- uses: ./.github/actions/setup
3524
- name: setup git
3625
run: |
3726
git config --local user.email '[email protected]'
@@ -44,33 +33,7 @@ jobs:
4433
- name: bump version
4534
run: npm version ${{env.NEXT_ALPHA}} --allow-same-version --no-git-tag-version
4635
- name: create tag
47-
run: git tag v${{env.NEXT_ALPHA}}-ember-source
48-
- name: build for publish
49-
env:
50-
BUILD_TYPE: alpha
51-
OVERRIDE_FEATURES: ''
52-
run: node bin/build-for-publishing.js
53-
- name: publish to npm
54-
run: npm publish
36+
run: git tag v${{env.NEXT_ALPHA}}-ember-source
5537
- name: push tag
56-
# Push in a way that will NOT trigger other workflows
57-
run: git push origin v${{env.NEXT_ALPHA}}-ember-source
58-
59-
notify:
60-
name: Notify Discord
61-
runs-on: ubuntu-latest
62-
needs:
63-
[
64-
test,
65-
release,
66-
]
67-
if: failure()
68-
steps:
69-
- uses: sarisia/actions-status-discord@v1
70-
with:
71-
webhook: ${{ secrets.FRAMEWORK_WEBHOOK }}
72-
status: 'Failure'
73-
title: 'Ember.js Alpha Release'
74-
color: 0xcc0000
75-
url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
76-
username: GitHub Actions
38+
# Push in a way that WILL trigger other workflows
39+
run: git push https://${GITHUB_ACTOR}:${{ secrets.PERSONAL_TOKEN }}@github.com/${GITHUB_REPOSITORY} v${{env.NEXT_ALPHA}}-ember-source

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ permissions:
1919
contents: read
2020

2121
jobs:
22-
ci:
22+
tests:
2323
uses: ./.github/workflows/ci-jobs.yml
2424
publish:
2525
name: Publish channel to s3
2626
runs-on: ubuntu-latest
27-
needs: [ci]
27+
needs: [ tests ]
2828
# Only run on pushes to branches that are not from the cron workflow
2929
if: github.event_name == 'push' && contains(github.ref, 'cron') != true
3030
steps:
@@ -42,7 +42,7 @@ jobs:
4242
publish-alpha:
4343
name: Publish alpha from default branch
4444
runs-on: ubuntu-latest
45-
needs: [ ci ]
45+
needs: [ tests ]
4646
# Only run on pushes to main
4747
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
4848
steps:
@@ -62,7 +62,7 @@ jobs:
6262
notify:
6363
name: Notify Discord
6464
runs-on: ubuntu-latest
65-
needs: [ ci ]
65+
needs: [ tests ]
6666
if: failure() && contains(github.ref, 'cron') == true
6767
steps:
6868
- uses: sarisia/actions-status-discord@v1
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
tests:
10+
uses: ./.github/workflows/ci-jobs.yml
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
needs: [ tests ]
15+
permissions:
16+
contents: read
17+
id-token: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: ./.github/actions/setup
21+
with:
22+
node-version: 20
23+
- name: Update npm
24+
run: npm install -g npm@latest # npm >= 11.5.1 is needed
25+
- name: Build for Publish (Alpha)
26+
if: contains(github.ref, 'alpha')
27+
env:
28+
BUILD_TYPE: alpha
29+
OVERRIDE_FEATURES: ''
30+
run: node bin/build-for-publishing.js
31+
- name: Build for Publish
32+
if: !contains(github.ref, 'alpha')
33+
run: node bin/build-for-publishing.js
34+
- name: publish to npm
35+
run: npm publish
36+
notify-failure:
37+
name: Notify Discord of Release Failure
38+
runs-on: ubuntu-latest
39+
needs: [release]
40+
if: failure()
41+
steps:
42+
- uses: sarisia/actions-status-discord@v1
43+
with:
44+
webhook: ${{ secrets.FRAMEWORK_WEBHOOK }}
45+
status: 'Failure'
46+
title: 'Failed to release ember-source ${{ github.ref_name }}'
47+
color: 0xcc0000
48+
url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
49+
username: GitHub Actions
50+
notify-success:
51+
name: Notify Discord of Release Success
52+
runs-on: ubuntu-latest
53+
needs: [release]
54+
if: success()
55+
steps:
56+
- uses: sarisia/actions-status-discord@v1
57+
with:
58+
webhook: ${{ secrets.FRAMEWORK_WEBHOOK }}
59+
status: 'Success'
60+
title: 'Released ember-source ${{ github.ref_name }}'
61+
color: 0x2ecc71
62+
url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
63+
username: GitHub Actions

0 commit comments

Comments
 (0)