Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .env.copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VITE_PROXY_SUBSTACK_ORIGIN=xxxx
VITE_PROXY_SUBSTACK_PATH=xxxx
VITE_PROXY_GOODREADS_ORIGIN=xxxx
VITE_PROXY_GOODREADS_PATH=xxxx
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

## Checklist

- [ ] This PR targets a release branch named `release/patch`, `release/minor`, or `release/major` as appropriate.
- [ ] `package.json` has been bumped with the correct semver increment for this release.
- [ ] `package-lock.json` (and any other lockfiles) have been updated and match the version in `package.json`.
- [ ] The code follows the repository's coding standards and style guidelines.
- [ ] All tests have been written or updated to cover the changes in this PR.
- [ ] The code passes all existing tests.
- [ ] Documentation has been updated to reflect any changes in functionality.
- [ ] Any new dependencies have been documented (if applicable).
- [ ] Any necessary migration steps have been outlined (if applicable).
- [ ] The code has been reviewed by at least one other team member.
- [ ] The branch is up-to-date with the latest changes from the main/master branch.
- [ ] The branch is up-to-date with the latest changes from the main branch.

## Testing Instructions

Expand Down
102 changes: 64 additions & 38 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,80 @@
name: Bump version, commit and push tag
# This workflow is triggered on push to a release branch (release/patch, release/minor, release/major).
# It uses the npm-get-version-action to get the current version from package.json and bumps the version based on the branch name.
# It also commits the changes made to package.json and pushes the tag to the repository.
name: Prepare release version

on:
push:
branches:
- 'release/*'
workflow_call:
- release/**
workflow_dispatch:

concurrency:
group: bump-version-${{ github.ref }}
cancel-in-progress: false

jobs:
bump_version:
# Only run if the PR is from a release branch (release/patch, release/minor, release/major)
if: ${{ github.ref_name == 'release/patch' || github.ref_name == 'release/minor' || github.ref_name == 'release/major' }}
bump:
name: Bump package version
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x ]
permissions:
contents: write
steps:
# Checkout the repo
- uses: actions/checkout@v4
# Setup node
- uses: actions/setup-node@v4
- name: Validate release branch naming
run: |
case "${GITHUB_REF_NAME}" in
release/patch|release/minor|release/major)
echo "Release branch ${GITHUB_REF_NAME} accepted."
;;
*)
echo "Invalid release branch name: ${GITHUB_REF_NAME}"
exit 1
;;
esac

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 20

- name: Install dependencies
run: npm install
run: npm ci

- name: Setup Git user
- name: Run unit tests
run: npm test --if-present

- name: Determine bump type
id: bump
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
case "${GITHUB_REF_NAME}" in
release/patch) echo "type=patch" >>"$GITHUB_OUTPUT" ;;
release/minor) echo "type=minor" >>"$GITHUB_OUTPUT" ;;
release/major) echo "type=major" >>"$GITHUB_OUTPUT" ;;
esac

- name: Check for uncommitted changes
- name: Configure git author
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Uncommitted changes detected. Committing..."
git add .
git commit -m "Pre-version bump changes"
else
echo "Working directory clean. Proceeding with version bump."
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Bump version patch
if: github.ref == 'refs/heads/release/patch'
run: npm run version:patch && git push --follow-tags
- name: Bump package version
run: |
npm version ${{ steps.bump.outputs.type }} --no-git-tag-version --commit-hooks false
VERSION="$(node -p "require('./package.json').version")"
echo "version=${VERSION}" >>"$GITHUB_OUTPUT"
id: version

- name: Bump version minor
if: github.ref == 'refs/heads/release/minor'
run: npm run version:minor && git push --follow-tags
- name: Commit version bump
run: |
if git status --porcelain | grep .; then
git add package.json package-lock.json
git commit -m "chore: bump version to v${{ steps.version.outputs.version }}"
else
echo "No changes to commit."
fi

- name: Bump version major
if: github.ref == 'refs/heads/release/major'
run: npm run version:major && git push --follow-tags
- name: Push changes
if: github.ref_protected != 'true'
run: git push --set-upstream origin "${GITHUB_REF_NAME}"
148 changes: 108 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,121 @@
name: CI
# This workflow is triggered on push to the main branch.
# It uses the npm-get-version-action to get the current version from package.json and creates a GitHub release from the latest tag.
# It also publishes the package to NPM.
name: Release

on:
push:
branches:
- 'main'
- main
workflow_dispatch:

concurrency:
group: release-main
cancel-in-progress: false

jobs:
build:
publish:
name: Publish package and tag release
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
node-version: [ 20.x ]
packages: write
id-token: write
steps:
# Checkout the repo
- uses: actions/checkout@v4
with :
ref: ${{ github.refs }}
# Setup node
- uses: actions/setup-node@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
node-version: ${{ matrix.node-version }}
# Add the registry URL to publish to NPM (optional)
registry-url: 'https://registry.npmjs.org'
# Add the scope of the package to publish to NPM (optional)
scope: '@rohit1901'
# Install dependencies
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org

- name: Install dependencies
if: ${{ success() }}
run: npm install
# Get the current version from package.json
- name: Get the current version from package.json
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
# Build the project
- name: Build the project
if: ${{ success() }}
run: npm ci

- name: Run tests
run: npm test --if-present

- name: Build package
run: npm run build
# Create a GitHub release
- name: Create a GitHub Release from the latest tag
if: ${{ success() }}
run: gh release create v${{ steps.package-version.outputs.current-version }}

- name: Ensure npm publish token is available
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to NPM
- name: Publish to NPM
if: ${{ success() }}
run: npm publish --access public
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: |
if [ -z "$NPM_PUBLISH_TOKEN" ]; then
echo "NPM_PUBLISH_TOKEN secret is required to publish."
exit 1
fi

- name: Determine package metadata
id: pkg
run: |
node <<'NODE' >> "$GITHUB_OUTPUT"
const pkg = require('./package.json');
console.log(`name=${pkg.name}`);
console.log(`version=${pkg.version}`);
NODE

- name: Check npm registry for existing version
id: registry
env:
PACKAGE: ${{ steps.pkg.outputs.name }}
VERSION: ${{ steps.pkg.outputs.version }}
run: |
if npm view "${PACKAGE}@${VERSION}" version >/dev/null 2>&1; then
echo "Version ${PACKAGE}@${VERSION} already exists on the npm registry."
echo "registry_has_version=true" >> "$GITHUB_OUTPUT"
else
echo "Version ${PACKAGE}@${VERSION} not found on the npm registry."
echo "registry_has_version=false" >> "$GITHUB_OUTPUT"
fi

- name: Ensure git tag exists
id: tag
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
TAG: v${{ steps.pkg.outputs.version }}
run: |
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
echo "Tag ${TAG} already exists."
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
else
git tag "${TAG}"
git push origin "${TAG}"
echo "tag_exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Write release summary
run: |
{
echo "## Release pipeline"
echo "- Package: \`${{ steps.pkg.outputs.name }}\`"
echo "- Version: \`v${{ steps.pkg.outputs.version }}\`"
if [ "${{ steps.tag.outputs.tag_exists }}" = "true" ]; then
echo "- Git tag: already existed (reusing existing tag)"
else
echo "- Git tag: created for this run"
fi
if [ "${{ steps.registry.outputs.registry_has_version }}" = "true" ]; then
echo "- Registry: version already published (publish will be skipped)"
else
echo "- Registry: version not yet published"
fi
} >> "$GITHUB_STEP_SUMMARY"

- name: Publish to npm
if: steps.registry.outputs.registry_has_version != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: npm publish --access public --provenance

- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ steps.pkg.outputs.version }}
run: |
if gh release view "${TAG}" >/dev/null 2>&1; then
echo "Release ${TAG} already exists."
else
gh release create "${TAG}" --title "${TAG}" --generate-notes
fi
Loading