Skip to content

Commit 5e6a6a2

Browse files
authored
Merge pull request #105 from add2cal/dev
Dev
2 parents ff611c3 + d1d0d21 commit 5e6a6a2

File tree

5 files changed

+504
-433
lines changed

5 files changed

+504
-433
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: 'CodeQL Analysis'
22

33
on:
4-
push:
5-
branches: [main, dev]
64
pull_request:
75
branches: [main, dev]
86

.github/workflows/npm-publish.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,67 @@ name: npm publish
55

66
on:
77
release:
8-
types: [created]
8+
types: [published]
9+
10+
env:
11+
TAG: '${{ github.event.release.tag_name }}'
912

1013
jobs:
14+
validate-release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
- name: Validate version tag pattern
20+
run: |
21+
if [[ ! "${{ env.TAG }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
22+
echo "Version tag ${{ env.TAG }} invalid."
23+
exit 1
24+
fi
25+
- name: Verify the tag is based off the main branch
26+
run: |
27+
if [[ "${{ github.event.release.target_commitish }}" != "main" ]]; then
28+
echo "Release is not based on main branch but ${{ github.event.release.target_commitish }}"
29+
exit 1
30+
fi
31+
- name: Make sure tag matches package.json version
32+
run: |
33+
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version);")
34+
VERSION=$(echo "$TAG" | sed 's/v//g')
35+
if [ "$PACKAGE_VERSION" != "$VERSION" ]; then
36+
echo "Different versions between package.json ($PACKAGE_VERSION) and release tag ($VERSION)"
37+
exit 1
38+
fi
39+
1140
test:
1241
runs-on: ubuntu-latest
42+
needs: validate-release
1343
steps:
1444
- uses: actions/checkout@v4
1545
- uses: actions/setup-node@v4
1646
with:
17-
node-version: 20
47+
node-version: 22
1848
- run: npm ci
49+
- run: npm run eslint
1950
- run: npm test
2051

2152
build-and-publish:
22-
needs: test
2353
runs-on: ubuntu-latest
54+
needs: test
55+
permissions:
56+
contents: read
57+
id-token: write
2458
steps:
2559
- uses: actions/checkout@v4
2660
- uses: actions/setup-node@v4
2761
with:
28-
node-version: 20
62+
node-version: 22
2963
registry-url: https://registry.npmjs.org/
3064
cache: 'npm'
65+
- run: npm install -g npm
3166
- run: npm ci
3267
- run: npm run build
33-
- run: npm publish
68+
- name: Publish package
69+
run: npm publish --provenance --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
3470
env:
35-
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}
71+
NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![Add to Calendar Button React Wrapper](https://github.com/add2cal/add-to-calendar-button-react/blob/main/assets/readme-header.png?raw=true)
22

33
![Version](https://img.shields.io/npm/v/add-to-calendar-button-react?style=for-the-badge&label=Version)
4-
[![Parent Script Version](https://img.shields.io/badge/Parent%20Script%20Version-v2.11.5-blue?style=for-the-badge)](https://github.com/add2cal/add-to-calendar-button)
4+
[![Parent Script Version](https://img.shields.io/badge/Parent%20Script%20Version-v2.12.1-blue?style=for-the-badge)](https://github.com/add2cal/add-to-calendar-button)
55
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/add-to-calendar-button-react?style=for-the-badge)](https://www.npmjs.com/package/add-to-calendar-button-react)
66
[![npm Installations](https://img.shields.io/npm/dt/add-to-calendar-button-react?label=npm%20Installations&style=for-the-badge)](https://www.npmjs.com/package/add-to-calendar-button-react)
77

0 commit comments

Comments
 (0)