This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (98 loc) · 3.28 KB
/
start-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
name: Release
on:
workflow_dispatch:
inputs:
type:
description: What type of version increment should be done?
default: patch
type: choice
options:
- patch
- minor
- major
required: true
releaseMessage:
description: The message to put in the release
type: string
required: false
permissions:
contents: read
actions: read
security-events: write
jobs:
qa:
name: Quality Assurance
permissions:
contents: read
actions: read
security-events: write
uses: ./.github/workflows/quality-assurance.yml
if: github.ref == 'refs/heads/main'
versioning:
name: Versioning
runs-on: ubuntu-22.04
permissions:
contents: read
if: github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.version.outputs.version }}
minor_version: ${{ steps.version.outputs.minor_version }}
major_version: ${{ steps.version.outputs.major_version }}
previous_version: ${{ steps.version.outputs.previous_version }}
previous_version_ref: ${{ steps.version.outputs.previous_version_ref }}
steps:
- uses: oss-actions/auto-semver@v0
id: version
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
type: ${{ inputs.type }}
release:
name: Release
runs-on: ubuntu-22.04
permissions:
contents: write
needs: [qa, versioning]
if: github.ref != needs.versioning.outputs.previous_version_ref
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Build
run: npm install && npm run ci:build && npm prune --production
- name: 'Apply version ${{ needs.versioning.outputs.version }} (major: ${{ needs.versioning.outputs.major_version }}, minor: ${{ needs.versioning.outputs.minor_version }})'
env:
VERSION: ${{ needs.versioning.outputs.version }}
run: |
node -e 'const pkg = require("./package.json"); pkg.version = process.env.VERSION.substring(1); fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n")'
- name: Git Author Config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Versioning
run: git tag $VERSION
env:
VERSION: ${{ needs.versioning.outputs.version }}
- name: Versioning (minor)
run: git tag -f $VERSION
env:
VERSION: ${{ needs.versioning.outputs.minor_version }}
- name: Versioning (major)
run: git tag -f $VERSION
env:
VERSION: ${{ needs.versioning.outputs.major_version }}
- name: Push tags
run: |
git push -u origin $VERSION
git push -fu origin {$MINOR_VERSION,$MAJOR_VERSION}
env:
VERSION: ${{ needs.versioning.outputs.version }}
MINOR_VERSION: ${{ needs.versioning.outputs.minor_version }}
MAJOR_VERSION: ${{ needs.versioning.outputs.major_version }}
- name: NPM Authentication
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: NPM Publish
run: npm publish