Skip to content

build:Refactor build and package scripts for release workflow #7

build:Refactor build and package scripts for release workflow

build:Refactor build and package scripts for release workflow #7

Workflow file for this run

name: Build and Release
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Dependencies
run: npm install
- name: Run build script
run: npm run build
- name: Install ncc
run: npm install @vercel/ncc -g
- name: Build with ncc
run: ncc build dist/index.js -o package
- name: Package with pkg
run: npx pkg package/index.js --targets node16-linux,node16-macos,node16-win -o package/chaoxing
- name: Capture the version tag
id: vars
run: echo "::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})"
- name: Rename artifacts to include version number
run: |
mv package/chaoxing-linux package/chaoxing-linux-${{ steps.vars.outputs.tag }}
mv package/chaoxing-macos package/chaoxing-macos-${{ steps.vars.outputs.tag }}
mv package/chaoxing-win.exe package/chaoxing-win-${{ steps.vars.outputs.tag }}.exe
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: chaoxing-${{ steps.vars.outputs.tag }}
path: |
package/chaoxing-${{ steps.vars.outputs.tag }}-linux
package/chaoxing-${{ steps.vars.outputs.tag }}-macos
package/chaoxing-${{ steps.vars.outputs.tag }}-win.exe
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: chaoxing-${{ needs.build.outputs.tag }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
chaoxing-${{ needs.build.outputs.tag }}-linux
chaoxing-${{ needs.build.outputs.tag }}-macos
chaoxing-${{ needs.build.outputs.tag }}-win.exe
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}