Skip to content
Merged

Dev #105

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: 'CodeQL Analysis'

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]

Expand Down
48 changes: 42 additions & 6 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,67 @@ name: npm publish

on:
release:
types: [created]
types: [published]

env:
TAG: '${{ github.event.release.tag_name }}'

jobs:
validate-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate version tag pattern
run: |
if [[ ! "${{ env.TAG }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version tag ${{ env.TAG }} invalid."
exit 1
fi
- name: Verify the tag is based off the main branch
run: |
if [[ "${{ github.event.release.target_commitish }}" != "main" ]]; then
echo "Release is not based on main branch but ${{ github.event.release.target_commitish }}"
exit 1
fi
- name: Make sure tag matches package.json version
run: |
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version);")
VERSION=$(echo "$TAG" | sed 's/v//g')
if [ "$PACKAGE_VERSION" != "$VERSION" ]; then
echo "Different versions between package.json ($PACKAGE_VERSION) and release tag ($VERSION)"
exit 1
fi

test:
runs-on: ubuntu-latest
needs: validate-release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- run: npm ci
- run: npm run eslint
- run: npm test

build-and-publish:
needs: test
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
registry-url: https://registry.npmjs.org/
cache: 'npm'
- run: npm install -g npm
- run: npm ci
- run: npm run build
- run: npm publish
- name: Publish package
run: npm publish --provenance --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Add to Calendar Button React Wrapper](https://github.com/add2cal/add-to-calendar-button-react/blob/main/assets/readme-header.png?raw=true)

![Version](https://img.shields.io/npm/v/add-to-calendar-button-react?style=for-the-badge&label=Version)
[![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)
[![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)
[![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)
[![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)

Expand Down
Loading
Loading