From aabc3b902dd462dede151a6b5fe21daca1389d73 Mon Sep 17 00:00:00 2001 From: hi2hi Date: Tue, 3 Dec 2024 16:15:50 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E4=BF=AE=E6=94=B9=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-build.yml | 8 ++--- .github/workflows/release.yml | 53 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 940a1e8..496650f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -34,13 +34,13 @@ jobs: - name: Build Docker image run: | - docker build -t ghcr.io/${{ github.repository }}/nazhua:$VERSION . + docker build -t ghcr.io/${{ github.repository }}:$VERSION . - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push Docker image run: | - docker push ghcr.io/${{ github.repository }}/nazhua:$VERSION - docker tag ghcr.io/${{ github.repository }}/nazhua:$VERSION ghcr.io/${{ github.repository }}/nazhua:latest - docker push ghcr.io/${{ github.repository }}/nazhua:latest + docker push ghcr.io/${{ github.repository }}:$VERSION + docker tag ghcr.io/${{ github.repository }}:$VERSION ghcr.io/${{ github.repository }}:latest + docker push ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..674891b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Build and Release + +on: + push: + tags: + - main # 监听 main 分支的 push 操作 + workflow_dispatch: # 手动触发支持 + +jobs: + build-and-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' # 根据项目需求调整版本 + + - name: Get version from package.json + id: get_version + run: echo "VERSION=$(node -p 'require("./package.json").version')" >> $GITHUB_ENV + + - name: Install dependencies + run: npm install + + - name: Build project + run: npm run build + + - name: Archive dist folder + run: | + zip -r nazhua-$VERSION.zip dist + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref_name }} # 使用当前推送的标签名 + release_name: "Release ${{ github.ref_name }}" + body: | + $(git log -1 --pretty=format:%B) + draft: false + prerelease: false + + - name: Upload release to GitHub + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./nazhua-$VERSION.zip + asset_name: nazhua-$VERSION.zip + asset_content_type: application/zip