Skip to content

Commit 9ca2510

Browse files
committed
add github workflows
1 parent 1db39f9 commit 9ca2510

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/bat.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build and Test
2+
on: [push]
3+
permissions:
4+
contents: read
5+
6+
jobs:
7+
bat:
8+
name: Build and Test
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- uses: actions/checkout@v5
12+
- uses: actions/setup-node@v5
13+
with:
14+
node-version: 20
15+
- name: Perform npm tasks
16+
run: npm run ci

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: published
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
- name: Configure git
15+
run: |
16+
git config user.name 'Release Action'
17+
git config user.email '<>'
18+
- uses: actions/setup-node@v5
19+
with:
20+
node-version: 20
21+
22+
# Update package.json version to match the release tag
23+
- name: Update package version
24+
run: |
25+
git tag -d "${{ github.event.release.tag_name }}"
26+
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
27+
git add package.json package-lock.json
28+
git commit -m "[skip ci] Bump $VERSION"
29+
git push origin HEAD:main
30+
31+
# Build and test
32+
- name: Perform npm tasks
33+
run: npm run ci
34+
35+
# Create release with built artifacts
36+
- name: Create release artifacts
37+
run: |
38+
# Validate semantic versioning
39+
longVersion="${{github.event.release.tag_name}}"
40+
echo "Preparing release for version $longVersion"
41+
[[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1)
42+
43+
# Add the built artifacts (adjust folder names as needed)
44+
git add --force dist lib
45+
46+
# Create commit with built code
47+
MESSAGE="Build for $(git rev-parse --short HEAD)"
48+
git commit --allow-empty -m "$MESSAGE"
49+
50+
# Tag this commit with the release version
51+
git tag -f -a -m "Release $longVersion" $longVersion
52+
53+
# Push the release tag
54+
git push -f origin $longVersion

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org/

0 commit comments

Comments
 (0)