Skip to content

Commit

Permalink
Add release build action (#25)
Browse files Browse the repository at this point in the history
* Add release build action

* Add check on main PR

* Fix

* Adjust action name

* Fix

* Add condition
  • Loading branch information
slhmy authored Sep 29, 2023
1 parent 32ecc2e commit b616ca2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# production
/build
/dist
dist.zip

# misc
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions RELEASE_INFO.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tag_name: v0.0.1
release_name: Release v0.0.1
body: |
This release is automatically generated.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"start": "vite",
"start-mock": "vite --mode mock",
"build": "vite build",
"build-and-zip": "vite build && zip -r dist.zip dist",
"init-mock": "npx msw init public --no-save",
"prettier": "npx prettier --write \"src/**/*.{ts,tsx}\"",
"prettier:check": "npx prettier --check \"src/**/*.{ts,tsx}\"",
Expand Down

0 comments on commit b616ca2

Please sign in to comment.