-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (72 loc) · 2.73 KB
/
tag.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
name: useaestrium/tag
on:
push:
tags:
- '*.*.*'
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
tag:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [17]
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout 🛎
uses: actions/checkout@v3
# Setup .npmrc file to publish to GitHub Packages
- name: Setup node env 🏗 and .npmrc file to publish to GitHub Packages
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file:
scope: '@observerly'
- name: Cache node_modules 📦
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install project dependencies 👨🏻💻
run: yarn
env:
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run vitest tests 🧪
run: yarn test
# Check the previous tag to the current tag
- name: Set GITHUB_REF tag to the output
id: set-tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Check GITHUB_REF tag is of correct '*.*.*' format
id: check-tag
run: |
if [[ ${{ steps.set-tag.outputs.tag }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=match::true
fi
# Ensure that the pushed tag updates the package.json version number
- name: Update package.json version to GITHUB_REF tag
if: steps.check-tag.outputs.match == 'true'
env:
RELEASE_VERSION: ${{ steps.set-tag.outputs.tag }}
run: |
yarn version --new-version "$RELEASE_VERSION" --no-git-tag-version
# Commit the updated package.json file
- name: Commit package.json version
if: steps.check-tag.outputs.match == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "chore: Bumped package.json version => ${{ steps.set-tag.outputs.tag }}" -a
# Push the updated package.json file to the repository
- name: Push package.json version
if: steps.check-tag.outputs.match == 'true'
run: |
git push origin HEAD:main