Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release build action #25

Merged
merged 6 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading