fix:修复工作流 #24
Workflow file for this run
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: Release Workflow | |
on: | |
push: | |
tags: | |
- '*' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install | |
- name: Install global tsc-alias | |
run: npm install -g tsc-alias | |
- name: Build the project | |
run: npm run build | |
- name: Configure Git user information | |
run: | | |
git config user.name "GitHub Action" | |
git config user.email "action@github.com" | |
- name: Stash lib folder before switching branch | |
run: | | |
git add lib/ -f | |
git stash | |
- name: Checkout or create main branch | |
run: | | |
git fetch origin | |
git checkout main || git checkout -b main | |
git stash pop | |
- name: Prepare main branch | |
run: | | |
# Force add lib folder to bypass .gitignore | |
git add -f lib/ | |
# Remove src folder from main branch if it exists | |
[ -d "src" ] && git rm -rf src/ | |
# Remove .github folder from main branch if it exists | |
[ -d ".github" ] && git rm -rf .github/ | |
# Add other necessary files | |
git add -u | |
# Commit changes | |
git commit -m "Add built files from tag ${{ github.ref_name }}" || echo "No changes to commit" | |
- name: Push changes to main branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: git push origin main --force |