Skip to content
name: Test, Build and Publish to GitHub Packages
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
# Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Authenticate with GitHub Packages
- name: Authenticate with GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Install dependencies
- name: Install dependencies
run: yarn install
- name: Run tests
run: yarn test
# Build the package
- name: Build the package
run: yarn build
# # Publish the package to GitHub Packages
# - name: Publish to GitHub Packages
# run: yarn publish --access public --verbose # Or use 'restricted' for private packages
# - name: Zip build files
# run: zip -r build.zip ./dist # Change ./dist to your build directory
- name: Compress build files to tar.gz
run: tar -czvf build.tar.gz ./dist # Change ./dist to your build directory
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload build artifact to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build.zip
asset_name: build.zip
asset_content_type: application/zip