Skip to content

Merge pull request #5 from icsaba/release-please--branches--main--com… #12

Merge pull request #5 from icsaba/release-please--branches--main--com…

Merge pull request #5 from icsaba/release-please--branches--main--com… #12

name: Release and Publish
on:
push:
branches:
- main # Trigger on push to the main branch
jobs:
release:
name: Automated Release with NPM Publish
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
# Step 1: Checkout the repository
- name: Checkout
uses: actions/checkout@v3
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22' # Specify Node.js version
cache: 'yarn' # Use Yarn and cache dependencies
# Step 3: Install dependencies with Yarn
- name: Install dependencies
run: yarn install
# Step 4: Run tests (optional)
- name: Run tests
run: yarn test
# Step 5: Build the project (optional)
- name: Build project
run: yarn build
# Step 6: Use Release Please to automatically create a release
- name: Release Please
uses: google-github-actions/release-please-action@v4
with:
release-type: node # Can be node, npm, or based on your project type
package-name: lit-functions
token: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub automatically
publish:
name: Publish to npm
needs: release
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout
uses: actions/checkout@v3
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22' # Specify Node.js version
cache: 'yarn' # Use Yarn and cache dependencies
always-auth: true
# Step 3: Install dependencies with Yarn
- name: Install dependencies
run: yarn install
- name: Build library
run: yarn build
# Step 4: Publish to npm
- name: Publish to npm
run: yarn publish --non-interactive --access public
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}