Build and Release Frontend #18
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 Frontend | |
on: | |
push: | |
branches: | |
- master | |
release: | |
types: | |
- created | |
- published | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version' | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Dashboard code | |
uses: actions/checkout@v3 | |
# Set up pnpm | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
# Setup Node.js | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
cache: pnpm | |
# Install packages and build the project | |
- name: Install package and build | |
run: | | |
pnpm install --no-frozen-lockfile | |
pnpm build | |
# Zip the build output | |
- name: Zip build output | |
id: zip_output | |
run: | | |
zip -r yacd.zip ./public | |
# Upload the artifact | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: yacd | |
path: yacd.zip | |
Upload-Prerelease: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name == 'push' | |
steps: | |
# Download build artifact from build job | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: yacd | |
path: ./build/ | |
- name: Delete current release assets | |
uses: 8Mi-Tech/delete-release-assets-action@main | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: Prerelease | |
deleteOnlyFromDrafts: false | |
- name: Set Env | |
run: | | |
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV | |
shell: bash | |
- name: Tag Repo | |
uses: richardsimko/update-tag@v1 | |
with: | |
tag_name: Prerelease | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Prerelease | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: Prerelease | |
files: | | |
./build/*.zip | |
prerelease: true | |
Upload-Release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name == 'workflow_dispatch' | |
steps: | |
# Download build artifact from build job | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: yacd | |
path: ./build/ | |
- name: Upload Release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ success() }} | |
with: | |
tag_name: ${{ github.event.inputs.version }} | |
files: | | |
./build/*.zip |