-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 1.94 KB
/
Copy pathpublish.yml
File metadata and controls
60 lines (52 loc) · 1.94 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
57
58
59
60
name: Publish
on:
release:
types: published
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.update-package-version.outputs.version }}
steps:
- uses: actions/checkout@v5
- name: Configure git
run: |
git config user.name 'Release Action'
git config user.email '<>'
- uses: actions/setup-node@v5
with:
node-version: 20
# Update package.json version to match the release tag
- name: Update package version
id: update-package-version
run: |
git tag -d "${{ github.event.release.tag_name }}"
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
git add package.json package-lock.json
git commit -m "[skip ci] Bump $VERSION"
git pull --rebase origin main
git push origin HEAD:main
# Build and test
- name: Perform npm tasks
run: npm run ci
# Create release with built artifacts
- name: Create release artifacts
id: release_info
run: |
# Validate semantic versioning
longVersion="${{github.event.release.tag_name}}"
echo "Preparing release for version $longVersion"
[[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1)
# Add the built artifacts (adjust folder names as needed)
git add --force dist lib
# Create commit with built code
MESSAGE="Build for $(git rev-parse --short HEAD)"
git commit --allow-empty -m "$MESSAGE"
# Tag this commit with the release version
git tag -f -a -m "Release $longVersion" $longVersion
# Push the release tag
echo "Pushing new tag"
git push -f origin $longVersion