Skip to content

Commit 91bbe7f

Browse files
authored
Merge pull request #24 from opf/ci-automation-attempt
Another attempt at fixing the CI
2 parents cfa0345 + 6c08017 commit 91bbe7f

File tree

3 files changed

+71
-67
lines changed

3 files changed

+71
-67
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tag and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag-and-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # fetch all tags
19+
20+
- name: Get version from package.json
21+
id: get_version
22+
run: |
23+
VERSION=$(jq -r .version package.json)
24+
echo "version=$VERSION" >> $GITHUB_OUTPUT
25+
26+
- name: Check if tag exists
27+
id: check_tag
28+
run: |
29+
TAG="v${{ steps.get_version.outputs.version }}"
30+
if git rev-parse "$TAG" >/dev/null 2>&1; then
31+
echo "Tag $TAG exists. Skipping release."
32+
echo "tag_exists=true" >> $GITHUB_OUTPUT
33+
else
34+
echo "tag_exists=false" >> $GITHUB_OUTPUT
35+
fi
36+
37+
- name: Create and push tag
38+
if: steps.check_tag.outputs.tag_exists == 'false'
39+
run: |
40+
TAG="v${{ steps.get_version.outputs.version }}"
41+
git config user.name "github-actions[bot]"
42+
git config user.email "github-actions[bot]@users.noreply.github.com"
43+
git tag "$TAG"
44+
git push origin "$TAG"
45+
46+
- name: Setup Node
47+
if: steps.check_tag.outputs.tag_exists == 'false'
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: '22'
51+
52+
- name: Install dependencies
53+
if: steps.check_tag.outputs.tag_exists == 'false'
54+
run: npm ci
55+
56+
- name: Build library
57+
if: steps.check_tag.outputs.tag_exists == 'false'
58+
run: npm run build:lib
59+
60+
- name: Package build output
61+
if: steps.check_tag.outputs.tag_exists == 'false'
62+
run: npm pack
63+
64+
- name: Create GitHub Release
65+
if: steps.check_tag.outputs.tag_exists == 'false'
66+
uses: softprops/action-gh-release@v2
67+
with:
68+
tag_name: ${{ steps.get_version.outputs.version }}
69+
files: '*.tgz'
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tag-version.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)