forked from mebjas/html5-qrcode
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (52 loc) · 1.64 KB
/
ci.yml
File metadata and controls
55 lines (52 loc) · 1.64 KB
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
name: CI
on:
push:
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build package
run: |
npm run-script build
- name: Create Tag
if: |
contains(github.event.head_commit.message, '[BUILD]') || contains(github.event.head_commit.message, '[RELEASE:')
run: |
COMMIT_MESSAGE="${{ github.event.head_commit.message }}"
while IFS= read -r line; do
if [[ "$line" == *"[BUILD]"* ]]; then
TAG_NAME=${{ github.run_id }}
elif [[ "$line" == *"[RELEASE:"* ]]; then
VERSION=$(echo "$line" | grep -oP '(?<=\[RELEASE:)[^][]*(?=])')
if [ -z "$VERSION" ]; then
echo "No version found in the commit message"
exit 1
fi
TAG_NAME="${VERSION}"
fi
done <<< "$COMMIT_MESSAGE"
shopt -s extglob
rm -rf !(dist)
shopt -s dotglob
mv dist/* .
rm -rf dist
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Updated tag contents"
git tag -fa "$TAG_NAME" -m "Generated tag from GitHub Actions"
git push origin --tags