Publish 🚀 #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish 🚀 | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
required: true | |
default: '1.0.0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ github.event.inputs.version }} # Set VERSION at the job level | |
permissions: | |
packages: write | |
contents: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v4 | |
- name: Setup Node.js 🚀 | |
uses: actions/setup-node@v2 | |
with: | |
node-version-file: .nvmrc | |
- name: Install Dependencies 📦 | |
run: npm ci | |
- name: Lint Code 🧹 | |
run: npm run lint | |
- name: Test Code 🧪 | |
run: npm test | |
- name: Configure Git | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
- name: Update package.json and Create Tag | |
run: | | |
# Set up Node.js environment if not already done | |
npm version ${{ env.VERSION }} --no-git-tag-version | |
git config --global user.email "[email protected]" | |
git config --global user.name "Your Name" | |
git commit -am "chore: v${{ env.VERSION }} [skip ci]" | |
git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}" | |
git push origin main | |
git push origin "v${{ env.VERSION }}" | |
- name: Create Release 🚀 | |
if: github.ref == 'refs/heads/main' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Release v${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Zip dist folder | |
run: zip -r dist.zip dist/ | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist.zip | |
asset_name: plugin.zip | |
asset_content_type: application/zip |