Skip to content

Commit

Permalink
Create publish_package.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jul 21, 2024
1 parent a2a5754 commit 34cb3b3
Showing 1 changed file with 203 additions and 0 deletions.
203 changes: 203 additions & 0 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
name: Publish Package

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'


jobs:


# =============================================================================
# Build
# =============================================================================

build:

name: Build

runs-on: ubuntu-latest

steps:


-
name: Checkout
uses: actions/checkout@v4

-
name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x

# - name: Check if version has been updated
# id: check
# uses: EndBug/version-check@v2

-
name: NPM Install
# if: steps.check.outputs.changed == 'true'
run: |
npm clean-install
# -
# name: NPM Run Lint
# run: |
# npm run lint --if-present

-
name: NPM Run Test
run: |
npm run test --if-present
-
name: NPM Run Build
run: |
npm run build --if-present
-
name: Zip dist & node_modules
run: zip -9qry "build.zip" "./" -i "node_modules/*" -i "dist/*"

-
name: Upload build.zip
uses: actions/upload-artifact@v4
with:
name: build.zip
path: build.zip


# =============================================================================
# Create a GitHub Release
# =============================================================================

release:

name: Create GitHub Release

needs: build

runs-on: ubuntu-latest

steps:

-
name: Checkout
uses: actions/checkout@master

-
name: Download build.zip
uses: actions/download-artifact@v4
with:
name: build.zip

-
name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}

-
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: ./build.zip
asset_name: build.zip
asset_content_type: application/zip


# =============================================================================
# Publish to NPM
# =============================================================================

publish-npm:

name: Publish NPM

needs: build

runs-on: ubuntu-latest

steps:

-
name: Checkout
uses: actions/checkout@v4

-
name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/

-
name: Download build.zip
uses: actions/download-artifact@v4
with:
name: build.zip

-
name: Unzip build.zip
run: unzip -q -o build.zip

-
name: Publish NPM
run: |
cd dist
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.PUBLISH_NPM_TOKEN}}


# =============================================================================
# Publish to GitHub Packages
# =============================================================================

# publish-gpr:

# needs: build

# runs-on: ubuntu-latest

# permissions:
# contents: read
# packages: write

# steps:

# -
# # uses: actions/checkout@v4
# uses: actions/checkout@v4

# -
# uses: actions/setup-node@v4
# with:
# # node-version: 16
# node-version: 18
# registry-url: https://npm.pkg.github.com/
# # scope: '@scape-agency'

# -
# name: Download build.zip
# uses: actions/download-artifact@v4
# with:
# name: build.zip

# -
# name: Unzip build.zip
# run: unzip -q build.zip

# -
# run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 34cb3b3

Please sign in to comment.