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