-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (107 loc) · 3.72 KB
/
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
101
102
103
104
105
106
107
108
109
110
111
112
113
name: "Release"
on:
push:
branches:
- release/*
jobs:
call-shared-workflow:
uses: ./.github/workflows/shared-workflow.yml
package-version:
needs: call-shared-workflow
runs-on: ubuntu-latest
outputs:
packageVersion: ${{ steps.package_version_step.outputs.packageVersion }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
- name: Set package version
id: package_version_step
run: |
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
BRANCH_VERSION=$(printf '%s\n' ${GIT_BRANCH//release\//})
TAG_VERSION=$(git tag --list | sort -V | tail -n1)
VERSION="$(export BRANCH_VERSION="${BRANCH_VERSION}" && export TAG_VERSION="${TAG_VERSION}" && node .github/scripts/getVersion.js)"
echo "${VERSION}"
echo "packageVersion=${VERSION}" >> $GITHUB_OUTPUT
publish-beta:
needs: package-version
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.package-version.outputs.packageVersion }}
steps:
- uses: actions/download-artifact@v3
with:
name: mediateur-package
- name: Unpack artifact
run: |
tar zxvf mediateur-0.0.0.tgz
mv ./package/* ./
- uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: 'https://registry.npmjs.org'
- name: Set version in package.json
run: |
export PACKAGE_VERSION="${{ env.VERSION }}" && export DEPLOY_DATE=$(date +'%Y%m%d%H%M%S') && node -p "JSON.stringify({...require('./package.json'), version: process.env.PACKAGE_VERSION + '-beta.' + process.env.DEPLOY_DATE})" > new-package.json
rm -rf package.json
mv new-package.json package.json
- name: Publish beta version
run: |
npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
release:
needs: [publish-beta, package-version]
environment: production
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.package-version.outputs.packageVersion }}
steps:
- uses: actions/checkout@v3
- name: Push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false
default_prerelease_bump: false
custom_tag: ${{ env.VERSION }}
tag_prefix: ''
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
publish-latest:
needs: [release, package-version]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.package-version.outputs.packageVersion }}
steps:
- uses: actions/download-artifact@v3
with:
name: mediateur-package
- name: Unpack artifact
run: |
tar zxvf mediateur-0.0.0.tgz
mv ./package/* ./
- uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: 'https://registry.npmjs.org'
- name: Set version in package.json
run: |
export PACKAGE_VERSION="${{ env.VERSION }}" && node -p "JSON.stringify({...require('./package.json'), version: process.env.PACKAGE_VERSION})" > new-package.json
rm -rf package.json
mv new-package.json package.json
- name: Publish latest version
run: |
npm publish --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}