@@ -3,59 +3,93 @@ name: Pipeline
33on :
44 push :
55 branches : [main]
6- paths : ["package.json", "src/**", "tests/**"]
6+ paths :
7+ [
8+ " package.json" ,
9+ " pnpm-lock.yaml" ,
10+ " src/**" ,
11+ " tests/**" ,
12+ " .github/workflows/pipeline.yml" ,
13+ ]
714 pull_request :
815 branches : [main]
916 types : [opened, synchronize, reopened]
10- paths : ["package.json", "src/**", "tests/**"]
17+ paths :
18+ [
19+ " package.json" ,
20+ " pnpm-lock.yaml" ,
21+ " src/**" ,
22+ " tests/**" ,
23+ " .github/workflows/pipeline.yml" ,
24+ ]
1125 workflow_dispatch :
1226
1327concurrency :
1428 group : ${{ github.workflow }}-${{ github.ref }}
15- cancel-in-progress : true
29+ # Cancel in-progress runs on PRs (new push makes old run irrelevant)
30+ # but never cancel on main (could interrupt a release)
31+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
1632
1733jobs :
18- check :
19- name : Type Checking
34+ build :
35+ name : Building
2036 runs-on : ubuntu-latest
21-
2237 steps :
2338 - name : Checkout repository
2439 uses : actions/checkout@v4
2540
2641 - name : Setup Node.js
2742 uses : ./.github/actions/node
2843
29- - name : Run the type checker
30- run : pnpm check
44+ - name : Build all packages
45+ run : pnpm build
3146
32- lint :
33- name : Linting
34- runs-on : ubuntu-latest
47+ - name : Upload dist artifacts
48+ uses : actions/upload-artifact@v4
49+ with :
50+ name : dist
51+ path : dist/
52+ retention-days : 1
3553
54+ check :
55+ name : Type Checking
56+ needs : [build]
57+ runs-on : ubuntu-latest
3658 steps :
3759 - name : Checkout repository
3860 uses : actions/checkout@v4
3961
4062 - name : Setup Node.js
4163 uses : ./.github/actions/node
4264
43- - name : Run the linter
44- run : pnpm lint
65+ - name : Download dist artifacts
66+ uses : actions/download-artifact@v4
67+ with :
68+ name : dist
69+ path : dist/
4570
46- build :
47- name : Building
48- runs-on : ubuntu-latest
71+ - name : Run the type checker
72+ run : pnpm check
4973
74+ lint :
75+ name : Linting
76+ needs : [build]
77+ runs-on : ubuntu-latest
5078 steps :
5179 - name : Checkout repository
5280 uses : actions/checkout@v4
5381
5482 - name : Setup Node.js
5583 uses : ./.github/actions/node
5684
57- - name : Build the package
58- run : pnpm build
85+ - name : Download dist artifacts
86+ uses : actions/download-artifact@v4
87+ with :
88+ name : dist
89+ path : dist/
90+
91+ - name : Run the linter
92+ run : pnpm lint
5993
6094 test :
6195 name : Testing
@@ -69,16 +103,26 @@ jobs:
69103 - name : Setup Node.js
70104 uses : ./.github/actions/node
71105
106+ - name : Download dist artifacts
107+ uses : actions/download-artifact@v4
108+ with :
109+ name : dist
110+ path : packages
111+
72112 - name : Run tests
73113 run : pnpm test
74114
75115 process :
76116 name : Processing Changesets
77- needs : [test]
117+ needs : [check, lint, test]
78118 runs-on : ubuntu-latest
79119 outputs :
80120 published : ${{ steps.changesets.outputs.published }}
81121 if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
122+ permissions :
123+ contents : write
124+ id-token : write
125+ pull-requests : write
82126
83127 steps :
84128 - name : Checkout repository
@@ -95,39 +139,18 @@ jobs:
95139 publish : pnpm run release:publish
96140 title : " Pending Releases"
97141 commit : " Update changelog and release"
98- env :
99- GITHUB_TOKEN : ${{ secrets.GH_PR_TOKEN }}
100- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
101- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
102142
103143 - run : |
104144 echo "published=${{ steps.changesets.outputs.published }}" >> $GITHUB_OUTPUT
105145
106- deprecate :
107- name : Deprecating Beta Versions
108- needs : [process]
109- runs-on : ubuntu-latest
110- if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.process.outputs.published == 'true' }}
111-
112- steps :
113- - name : Deprecate beta versions
114- run : |
115- package=$(curl -s "https://registry.npmjs.org/enhanced-ms")
116- versions=$(echo "$package" | jq -r '.versions | to_entries | map(select(.value.deprecated | not)) | map(.key)')
117- beta_versions=$(echo "$versions" | jq -r '.[] | select(test("beta"))')
118- for version in $beta_versions; do
119- sleep 5
120- echo "Deprecating enhanced-ms@$version"
121- npm deprecate enhanced-ms@$version "This beta version has been merged into the latest release. Please upgrade to the latest version."
122- done
123- env :
124- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
125-
126146 snapshot :
127147 name : Releasing Snapshot
128148 needs : [process]
129149 runs-on : ubuntu-latest
130150 if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.process.outputs.published == 'false' }}
151+ permissions :
152+ contents : read
153+ id-token : write
131154
132155 steps :
133156 - name : Checkout repository
@@ -140,6 +163,3 @@ jobs:
140163 run : |
141164 pnpm run release:snapshot:version
142165 pnpm run release:snapshot:publish
143- env :
144- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
145- continue-on-error : true
0 commit comments