@@ -3,133 +3,134 @@ name: CD
33on :
44  push :
55    branches :
6-     -  ' ** ' 
6+       -  " ** " 
77    tags-ignore :
8-     #  Only create preview releases for branches
9-     #  (the `release` workflow creates actual releases for version tags):
10-     -  ' ** ' 
8+        #  Only create preview releases for branches
9+        #  (the `release` workflow creates actual releases for version tags):
10+       -  " ** " 
1111
1212env :
1313  CI : true 
1414jobs :
1515  prepare-deployment :
16-     runs-on : ubuntu-20.04  
16+     runs-on : ubuntu-latest  
1717    outputs :
1818      tag-slug : ${{ steps.determine-npm-tag.outputs.tag-slug }} 
1919      deployment-id : ${{ fromJson(steps.create-deployment.outputs.data || '{}').id || 'Skipped for Dependabot' }} 
2020    steps :
21-     - name : Create GitHub Deployment 
22-       if : github.actor != 'dependabot[bot]' 
23-       id : create-deployment 
24- 25-       with :
26-         route : POST /repos/:repository/deployments 
27-         repository : ${{ github.repository }} 
28-         ref : ${{ github.sha }} 
29-         environment : review 
30-         transient_environment : true 
31-         auto_merge : false 
32-         mediaType : ' {"previews": ["flash", "ant-man"]}' 
33-         #  The deployment runs in parallel with CI, so status checks will never have succeeded yet:
34-         required_contexts : ' [] ' 
35-       env :
36-         GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
37-     - name : Determine npm tag 
38-       if : github.actor != 'dependabot[bot]' 
39-       id : determine-npm-tag 
40-       run : | 
41-         # Remove non-alphanumeric characters 
42-         # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable 
43-         echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')" 
21+        - name : Create GitHub Deployment 
22+          if : github.actor != 'dependabot[bot]' 
23+          id : create-deployment 
24+ 25+          with :
26+            route : POST /repos/:repository/deployments 
27+            repository : ${{ github.repository }} 
28+            ref : ${{ github.sha }} 
29+            environment : review 
30+            transient_environment : true 
31+            auto_merge : false 
32+            mediaType : ' {"previews": ["flash", "ant-man"]}' 
33+            #  The deployment runs in parallel with CI, so status checks will never have succeeded yet:
34+            required_contexts : " [] " 
35+          env :
36+            GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
37+        - name : Determine npm tag 
38+          if : github.actor != 'dependabot[bot]' 
39+          id : determine-npm-tag 
40+          run : | 
41+            # Remove non-alphanumeric characters 
42+            # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable 
43+            echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')" 
4444
4545publish-npm :
46-     runs-on : ubuntu-20.04  
46+     runs-on : ubuntu-latest  
4747    needs : [prepare-deployment] 
4848    outputs :
4949      version-nr : ${{ steps.determine-npm-version.outputs.version-nr }} 
5050    steps :
51- 52-     - name : Mark GitHub Deployment as in progress 
53-       if : github.actor != 'dependabot[bot]' 
54-       id : start-deployment 
55- 56-       with :
57-         route : POST /repos/:repository/deployments/:deployment/statuses 
58-         repository : ${{ github.repository }} 
59-         deployment : ${{ needs.prepare-deployment.outputs.deployment-id }} 
60-         environment : review 
61-         description : " Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…" 
62-         log_url : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 
63-         state : in_progress 
64-         mediaType : ' {"previews": ["flash", "ant-man"]}' 
65-       env :
66-         GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
67- 68-       with :
69-         node-version : ' 16.x' 
70-         registry-url : ' https://registry.npmjs.org' 
71-     - name : Prepare prerelease version 
72-       if : github.actor != 'dependabot[bot]' 
73-       id : determine-npm-version 
74-       run : | 
75-         git config user.name $GITHUB_ACTOR 
76-         git config user.email gh-actions-${GITHUB_ACTOR}@github.com 
77-         # Unfortunately re-running a job does not change its run ID nor run number. 
78-         # To prevent re-releasing the same version when re-running the CD job, 
79-         # we incorporate a timestamp in the prerelease version: 
80-         TIMESTAMP=$(date --utc +%s) 
81-         # Make sure the prerelease is tagged with the branch name, and that they are sorted by build: 
82-         VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP) 
83-         echo "::set-output name=version-nr::$VERSION_NR" 
84- env :
85-         TAG_SLUG : ${{ needs.prepare-deployment.outputs.tag-slug }} 
86-     - run : npm ci 
87-     - name : Publish an npm tag for this branch 
88-       if : github.actor != 'dependabot[bot]' 
89-       run : | 
90-         # Unfortunately GitHub Actions does not currently let us do something like 
91-         #     if: secrets.NPM_TOKEN != '' 
92-         # so simply skip the command if the env var is not set: 
93-         if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi 
94-         if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi 
95-         if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi 
96-         if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi 
97-         if [ -n $NODE_AUTH_TOKEN ]; then echo "    npm install @inrupt/solid-ui-react@$TAG_SLUG"; fi 
98- env :
99-         NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }} 
100-         TAG_SLUG : ${{ needs.prepare-deployment.outputs.tag-slug }} 
101-     - name : Mark GitHub Deployment as successful 
102-       if : github.actor != 'dependabot[bot]' 
103- 104-       with :
105-         route : POST /repos/:repository/deployments/:deployment/statuses 
106-         repository : ${{ github.repository }} 
107-         deployment : ${{ needs.prepare-deployment.outputs.deployment-id }} 
108-         environment : review 
109-         environment_url : ' https://www.npmjs.com/package/@inrupt/solid-ui-react/v/${{ needs.prepare-deployment.outputs.tag-slug }}' 
110-         description : " Published to npm. To install, run: npm install @inrupt/solid-ui-react@${{ needs.prepare-deployment.outputs.tag-slug }}" 
111-         log_url : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 
112-         mediaType : ' {"previews": ["flash", "ant-man"]}' 
113-         state : success 
114-       env :
115-         GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
116-     - name : Mark GitHub Deployment as failed 
117- 118-       if : failure() && github.actor != 'dependabot[bot]' 
119-       with :
120-         route : POST /repos/:repository/deployments/:deployment/statuses 
121-         repository : ${{ github.repository }} 
122-         deployment : ${{ needs.prepare-deployment.outputs.deployment-id }} 
123-         environment : review 
124-         description : " Publication to npm failed. Review the GitHub Actions log for more information." 
125-         log_url : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 
126-         mediaType : ' {"previews": ["flash", "ant-man"]}' 
127-         state : failure 
128-       env :
129-         GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
130-     - name : Waiting for npm CDNs to update... 
131-       if : github.actor != 'dependabot[bot]' 
132-       run : | 
133-         echo "Giving npm some time to make the newly-published package available…" 
134-         sleep 5m 
135-         echo "Done — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." 
51+       - uses : actions/checkout@v3 
52+       - name : Mark GitHub Deployment as in progress 
53+         if : github.actor != 'dependabot[bot]' 
54+         id : start-deployment 
55+ 56+         with :
57+           route : POST /repos/:repository/deployments/:deployment/statuses 
58+           repository : ${{ github.repository }} 
59+           deployment : ${{ needs.prepare-deployment.outputs.deployment-id }} 
60+           environment : review 
61+           description : " Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…" 
62+           log_url : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 
63+           state : in_progress 
64+           mediaType : ' {"previews": ["flash", "ant-man"]}' 
65+         env :
66+           GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
67+       - uses : actions/setup-node@v3 
68+         with :
69+           node-version : " 16.x" 
70+           registry-url : " https://registry.npmjs.org" 
71+           cache : npm 
72+       - name : Prepare prerelease version 
73+         if : github.actor != 'dependabot[bot]' 
74+         id : determine-npm-version 
75+         run : | 
76+           git config user.name $GITHUB_ACTOR 
77+           git config user.email gh-actions-${GITHUB_ACTOR}@github.com 
78+           # Unfortunately re-running a job does not change its run ID nor run number. 
79+           # To prevent re-releasing the same version when re-running the CD job, 
80+           # we incorporate a timestamp in the prerelease version: 
81+           TIMESTAMP=$(date --utc +%s) 
82+           # Make sure the prerelease is tagged with the branch name, and that they are sorted by build: 
83+           VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP) 
84+           echo "::set-output name=version-nr::$VERSION_NR" 
85+ env :
86+           TAG_SLUG : ${{ needs.prepare-deployment.outputs.tag-slug }} 
87+       - run : npm ci 
88+       - name : Publish an npm tag for this branch 
89+         if : github.actor != 'dependabot[bot]' 
90+         run : | 
91+           # Unfortunately GitHub Actions does not currently let us do something like 
92+           #     if: secrets.NPM_TOKEN != '' 
93+           # so simply skip the command if the env var is not set: 
94+           if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi 
95+           if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi 
96+           if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi 
97+           if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi 
98+           if [ -n $NODE_AUTH_TOKEN ]; then echo "    npm install @inrupt/solid-ui-react@$TAG_SLUG"; fi 
99+ env :
100+           NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }} 
101+           TAG_SLUG : ${{ needs.prepare-deployment.outputs.tag-slug }} 
102+       - name : Mark GitHub Deployment as successful 
103+         if : github.actor != 'dependabot[bot]' 
104+ 105+         with :
106+           route : POST /repos/:repository/deployments/:deployment/statuses 
107+           repository : ${{ github.repository }} 
108+           deployment : ${{ needs.prepare-deployment.outputs.deployment-id }} 
109+           environment : review 
110+           environment_url : " https://www.npmjs.com/package/@inrupt/solid-ui-react/v/${{ needs.prepare-deployment.outputs.tag-slug }}" 
111+           description : " Published to npm. To install, run: npm install @inrupt/solid-ui-react@${{ needs.prepare-deployment.outputs.tag-slug }}" 
112+           log_url : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 
113+           mediaType : ' {"previews": ["flash", "ant-man"]}' 
114+           state : success 
115+         env :
116+           GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
117+       - name : Mark GitHub Deployment as failed 
118+ 119+         if : failure() && github.actor != 'dependabot[bot]' 
120+         with :
121+           route : POST /repos/:repository/deployments/:deployment/statuses 
122+           repository : ${{ github.repository }} 
123+           deployment : ${{ needs.prepare-deployment.outputs.deployment-id }} 
124+           environment : review 
125+           description : " Publication to npm failed. Review the GitHub Actions log for more information." 
126+           log_url : https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 
127+           mediaType : ' {"previews": ["flash", "ant-man"]}' 
128+           state : failure 
129+         env :
130+           GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}" 
131+       - name : Waiting for npm CDNs to update... 
132+         if : github.actor != 'dependabot[bot]' 
133+         run : | 
134+           echo "Giving npm some time to make the newly-published package available…" 
135+           sleep 5m 
136+           echo "Done — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." 
0 commit comments