forked from IdentityModel/oidc-client-js
-
Notifications
You must be signed in to change notification settings - Fork 3
100 lines (97 loc) · 3.83 KB
/
cd-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: CD-release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
env:
CI: true
jobs:
prepare-deployment:
runs-on: ubuntu-20.04
outputs:
deployment-id: ${{ fromJson(steps.create-deployment.outputs.data).id }}
steps:
- name: Create GitHub Deployment
id: create-deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments
repository: ${{ github.repository }}
ref: ${{ github.sha }}
environment: review
transient_environment: true
auto_merge: false
mediaType: '{"previews": ["flash", "ant-man"]}'
# The deployment runs in parallel with CI, so status checks will never have succeeded yet:
required_contexts: "[]"
env:
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
publish-npm:
runs-on: ubuntu-20.04
needs: [prepare-deployment]
steps:
- uses: actions/checkout@v3.3.0
- name: Mark GitHub Deployment as in progress
id: start-deployment
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
description: "Publishing to npm tag `${GITHUB_REF#refs/tags/v}`…"
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: in_progress
mediaType: '{"previews": ["flash", "ant-man"]}'
env:
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
- name: Prepare for publication to npm
uses: actions/setup-node@v3
with:
node-version: "12.x"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- name: Publish to npm
# If you want a package to be public (e.g. you'd expect
# `npm publish --access public` here), then just add this to the relevant
# `package.json` file:
# {
# "publishConfig": {
# "access": "public"
# }
# }
run: |
npm publish
echo "Packages published. To install, run:"
echo ""
echo " npm install @inrupt/oidc-client"
env:
NODE_AUTH_TOKEN: ${{ secrets.INRUPT_NPM_TOKEN }}
- name: Mark GitHub Deployment as successful
uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
environment_url: "https://www.npmjs.com/package/@inrupt/oidc-client/v/${GITHUB_REF#refs/tags/v}"
description: "Published to npm. To install, run: npm install @inrupt/oidc-client@${GITHUB_REF#refs/tags/v}"
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["flash", "ant-man"]}'
state: success
env:
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
- name: Mark GitHub Deployment as failed
uses: octokit/request-action@v2.x
if: failure()
with:
route: POST /repos/:repository/deployments/:deployment/statuses
repository: ${{ github.repository }}
deployment: ${{ needs.prepare-deployment.outputs.deployment-id }}
environment: review
description: "Publication to npm failed. Review the GitHub Actions log for more information."
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["flash", "ant-man"]}'
state: failure
env:
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"