@@ -13,49 +13,37 @@ jobs:
1313 runs-on : ubuntu-latest
1414 if : ${{ !github.event.created && github.repository != 'garronej/ts-ci' }}
1515 steps :
16- - uses : actions/checkout@v2.3.4
17- - uses : actions/setup-node@v2.1.3
16+ - uses : actions/checkout@v3
17+ - uses : actions/setup-node@v3
1818 - uses : bahmutov/npm-install@v1
19- - name : If this step fails run 'npm run lint' and 'npm run format' then commit again.
19+ - name : If this step fails run 'yarn lint' and 'yarn format' then commit again.
2020 run : |
21- PACKAGE_MANAGER=npm
22- if [ -f "./yarn.lock" ]; then
23- PACKAGE_MANAGER=yarn
24- fi
25- $PACKAGE_MANAGER run lint:check
26- $PACKAGE_MANAGER run format:check
21+ yarn lint:check
22+ yarn format:check
2723 test :
2824 runs-on : ${{ matrix.os }}
2925 needs : test_lint
3026 strategy :
3127 matrix :
32- node : [ '16 ' ]
33- os : [ ubuntu-latest ]
28+ node : [ '14', '15' ,'16', '17 ' ]
29+ os : [ windows-latest, ubuntu-latest ]
3430 name : Test with Node v${{ matrix.node }} on ${{ matrix.os }}
3531 steps :
36- - name : Tell if project is using npm or yarn
37- id : step1
38- uses : garronej/ts-ci@v1.1.8
39- with :
40- action_name : tell_if_project_uses_npm_or_yarn
41- - uses : actions/checkout@v2.3.4
42- - uses : actions/setup-node@v2.1.3
32+ - uses : actions/checkout@v3
33+ - uses : actions/setup-node@v3
4334 with :
4435 node-version : ${{ matrix.node }}
4536 - uses : bahmutov/npm-install@v1
46- - if : steps.step1.outputs.npm_or_yarn == 'yarn'
47- run : |
48- yarn build
49- yarn test
50- - if : steps.step1.outputs.npm_or_yarn == 'npm'
51- run : |
52- npm run build
53- npm test
37+ - run : yarn build
38+ - run : yarn test
39+
5440 check_if_version_upgraded :
5541 name : Check if version upgrade
56- # We run this only if it's a push on the default branch or if it's a PR from a
57- # branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.NPM_TOKEN is
58- # defined but GitHub Action don't allow it yet.
42+ # When someone forks the repo and opens a PR we want to enables the tests to be run (the previous jobs)
43+ # but obviously only us should be allowed to release.
44+ # In the following check we make sure that we own the branch this CI workflow is running on before continuing.
45+ # Without this check, trying to release would fail anyway because only us have the correct secret.NPM_TOKEN but
46+ # it's cleaner to stop the execution instead of letting the CI crash.
5947 if : |
6048 github.event_name == 'push' ||
6149 github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
@@ -65,35 +53,35 @@ jobs:
6553 from_version : ${{ steps.step1.outputs.from_version }}
6654 to_version : ${{ steps.step1.outputs.to_version }}
6755 is_upgraded_version : ${{ steps.step1.outputs.is_upgraded_version }}
68- is_release_beta : ${{steps.step1.outputs.is_release_beta }}
56+ is_pre_release : ${{steps.step1.outputs.is_pre_release }}
6957 steps :
70- - uses : garronej/ts-ci@v1 .1.8
58+ - uses : garronej/ts-ci@v2 .1.0
7159 id : step1
7260 with :
7361 action_name : is_package_json_version_upgraded
7462 branch : ${{ github.head_ref || github.ref }}
7563
7664 create_github_release :
7765 runs-on : ubuntu-latest
78- # We create a release only if the version have been upgraded and we are on a default branch
79- # PR on the default branch can release beta but not real release
66+ # We create release only if the version in the package.json have been upgraded and this CI is running against the main branch.
67+ # We allow branches with a PR open on main to publish pre- release (x.y.z-rc.u) but not actual releases.
8068 if : |
8169 needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' &&
8270 (
8371 github.event_name == 'push' ||
84- needs.check_if_version_upgraded.outputs.is_release_beta == 'true'
72+ needs.check_if_version_upgraded.outputs.is_pre_release == 'true'
8573 )
8674 needs :
8775 - check_if_version_upgraded
8876 steps :
89- - uses : softprops/action-gh-release@v0.1.14
77+ - uses : softprops/action-gh-release@v1
9078 with :
9179 name : Release v${{ needs.check_if_version_upgraded.outputs.to_version }}
9280 tag_name : v${{ needs.check_if_version_upgraded.outputs.to_version }}
9381 target_commitish : ${{ github.head_ref || github.ref }}
9482 generate_release_notes : true
9583 draft : false
96- prerelease : ${{ needs.check_if_version_upgraded.outputs.is_release_beta == 'true' }}
84+ prerelease : ${{ needs.check_if_version_upgraded.outputs.is_pre_release == 'true' }}
9785 env :
9886 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9987
@@ -103,23 +91,20 @@ jobs:
10391 - create_github_release
10492 - check_if_version_upgraded
10593 steps :
106- - uses : actions/checkout@v2.3.4
94+ - uses : actions/checkout@v3
10795 with :
10896 ref : ${{ github.ref }}
109- - uses : actions/setup-node@v2.1.3
97+ - uses : actions/setup-node@v3
11098 with :
111- node-version : ' 17'
11299 registry-url : https://registry.npmjs.org/
113100 - uses : bahmutov/npm-install@v1
114- - run : |
115- PACKAGE_MANAGER=npm
116- if [ -f "./yarn.lock" ]; then
117- PACKAGE_MANAGER=yarn
118- fi
119- $PACKAGE_MANAGER run build
120- - run : npx -y -p denoify@1.0.5 enable_short_npm_import_path
101+ - run : yarn build
102+ - run : npx -y -p denoify@1.3.0 enable_short_npm_import_path
121103 env :
122104 DRY_RUN : " 0"
105+ - uses : garronej/ts-ci@v2.1.0
106+ with :
107+ action_name : remove_dark_mode_specific_images_from_readme
123108 - name : Publishing on NPM
124109 run : |
125110 if [ "$(npm show . version)" = "$VERSION" ]; then
@@ -131,11 +116,11 @@ jobs:
131116 false
132117 fi
133118 EXTRA_ARGS=""
134- if [ "$IS_BETA " = "true" ]; then
135- EXTRA_ARGS="--tag beta "
119+ if [ "$IS_PRE_RELEASE " = "true" ]; then
120+ EXTRA_ARGS="--tag next "
136121 fi
137- npm publish --access public $EXTRA_ARGS
122+ npm publish $EXTRA_ARGS
138123 env :
139124 NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
140125 VERSION : ${{ needs.check_if_version_upgraded.outputs.to_version }}
141- IS_BETA : ${{ needs.check_if_version_upgraded.outputs.is_release_beta }}
126+ IS_PRE_RELEASE : ${{ needs.check_if_version_upgraded.outputs.is_pre_release }}
0 commit comments