-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (53 loc) · 1.88 KB
/
ci.yml
File metadata and controls
56 lines (53 loc) · 1.88 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
56
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Build and Test
run: |
npm run test
npm run build
release:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for version bump
id: version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if git rev-parse "${PACKAGE_VERSION}" >/dev/null 2>&1; then
echo "Tag ${PACKAGE_VERSION} already exists, skipping release."
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "New version detected: ${PACKAGE_VERSION}"
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=${PACKAGE_VERSION}" >> "$GITHUB_OUTPUT"
fi
- name: Create tag and GitHub Release
if: steps.version.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=${{ steps.version.outputs.version }}
git tag "${VERSION}"
git push origin "${VERSION}"
gh release create "${VERSION}" --title "${VERSION}" --generate-notes