Skip to content

Merge pull request #32 from baoduy/develop #33

Merge pull request #32 from baoduy/develop

Merge pull request #32 from baoduy/develop #33

# This is a basic workflow to help you get started with Actions
name: build-publish
on:
push:
branches: ['main']
#paths:
# - src/**
env:
Enable_Release: 'true'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Versioning
- name: Get version and version code
uses: xom9ikk/version-by-tag@v1
id: versioning
with:
isUseGithubRunNumber: true
- uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
with:
current_version: ${{ steps.versioning.outputs.semver }}
level: patch
- name: Print Variables
run: |
echo "New version: ${{ steps.bump-semver.outputs.new_version }}"
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://registry.npmjs.org/'
- run: npm install --force
- name: Run Lints
continue-on-error: true
run: npm run lint
#Fix node_modules/openpgp/openpgp.d.ts:10:46 - error
# - name: Replace text in file
# run: |
# sed -i 's/NodeStream as GenericNodeStream/NodeWebStream as GenericNodeStream/g' node_modules/openpgp/openpgp.d.ts
# - name: Test
# continue-on-error: true
# run: |
# export NODE_OPTIONS="--max_old_space_size=4096"
# npm test
- name: Build and Pack
run: |
export NODE_OPTIONS="--max_old_space_size=4096"
npm run build
- name: Update version in package.json
run: |
cd .out-bin
sed -i 's/"version": "0.0.1"/"version": "${{ steps.bump-semver.outputs.new_version }}"/' package.json
# Create Release
- name: Create Release
id: create_release
if: ${{ env.Enable_Release == 'true' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump-semver.outputs.new_version }}
release_name: Release ${{ steps.bump-semver.outputs.new_version }}
draft: false
prerelease: false
- name: Publish to npm
if: ${{ env.Enable_Release == 'true' }}
run: |
cd .out-bin
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@drunk-pulumi"
npm publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}