Add release build action (#25) #6
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: Build and Release | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install tools | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y zip | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: Read Release Info | |
id: read_release_info | |
uses: actions/github-script@v4 | |
with: | |
script: | | |
const fs = require('fs'); | |
const yaml = require('js-yaml'); | |
const releaseInfo = yaml.load(fs.readFileSync('RELEASE_INFO.yml', 'utf8')); | |
return releaseInfo; | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
if: github.event_name == 'push' | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.read_release_info.outputs.tag_name }} | |
release_name: ${{ steps.read_release_info.outputs.release_name }} | |
body: ${{ steps.read_release_info.outputs.description }} | |
- name: Upload Release Asset | |
if: github.event_name == 'push' | |
id: upload-release-asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist.zip | |
asset_name: dist.zip | |
asset_content_type: application/zip |