From 8afbf14cbe84dd7988d2023d15344b97d868424a Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Mon, 9 Mar 2026 20:13:51 +0800 Subject: [PATCH] add release action --- .github/release-template.md | 19 ++++++++++ .github/workflows/deploy-api.yml | 13 ++++--- .github/workflows/release.yml | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 .github/release-template.md create mode 100644 .github/workflows/release.yml diff --git a/.github/release-template.md b/.github/release-template.md new file mode 100644 index 0000000..2db29b9 --- /dev/null +++ b/.github/release-template.md @@ -0,0 +1,19 @@ +## Mega Release + +Version: ${VERSION} + +--- + +## Docker Images + +### campsite-api + +docker pull ghcr.io/web3infra-foundation/campsite-api:${VERSION} + + + +--- + +## Changes + +- Describe major changes here diff --git a/.github/workflows/deploy-api.yml b/.github/workflows/deploy-api.yml index 44cb573..6270fd4 100644 --- a/.github/workflows/deploy-api.yml +++ b/.github/workflows/deploy-api.yml @@ -5,10 +5,9 @@ on: env: REGISTRY_ALIAS: m8q5m4u3 - REPOSITORY: mega - IMAGE_TAG_BASE: campsite-0.1.0-pre-release + REPOSITORY: mega/campsite-api + IMAGE_TAG_BASE: 0.1.0-pre-release GCP_PROJECT_ID: infra-20250121-20260121-0235 - GCP_REPOSITORY: mega RUBY_VERSION: 3.3.4 NODE_VERSION: 18.16.1 BUNDLER_VERSION: 2.3.14 @@ -65,7 +64,7 @@ jobs: - name: Build & push amd64 image (AWS + GCP) env: AWS_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} - GCP_IMAGE_BASE: us-central1-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPOSITORY }}/${{ env.REPOSITORY }} + GCP_IMAGE_BASE: us-central1-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.REPOSITORY }} run: | set -euo pipefail @@ -113,7 +112,7 @@ jobs: docker manifest push "$IMAGE_BASE:${{ env.IMAGE_TAG_BASE }}" deploy-aws: - if: ${{ github.repository == 'web3infra-foundation/mega' }} + if: ${{ github.repository == 'web3infra-foundation/campsite' }} needs: manifest runs-on: ubuntu-latest strategy: @@ -137,7 +136,7 @@ jobs: deploy-gcp: needs: manifest - if: ${{ github.repository == 'web3infra-foundation/mega' }} + if: ${{ github.repository == 'web3infra-foundation/campsite' }} runs-on: ubuntu-latest steps: - name: Auth to GCP @@ -148,7 +147,7 @@ jobs: - name: Deploy to Cloud Run (force new revision) env: REGION: asia-east1 - SERVICE_NAME: buck2-hub-campsite + SERVICE_NAME: buck2hub-campsite run: | set -euo pipefail diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4005058 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Release + +on: + push: + tags: + - "v*" + +env: + RUBY_VERSION: 3.3.4 + NODE_VERSION: 18.16.1 + BUNDLER_VERSION: 2.3.14 +permissions: + contents: write + packages: write +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Tag + id: tag + run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: api + file: api/Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/campsite-api:${{ steps.tag.outputs.TAG }} + ghcr.io/${{ github.repository_owner }}/campsite-api:latest + build-args: | + RUBY_VERSION=${{ env.RUBY_VERSION }} + NODE_VERSION=${{ env.NODE_VERSION }} + BUNDLER_VERSION=${{ env.BUNDLER_VERSION }} + create-release: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + + - name: Generate Release Notes + run: | + VERSION=${GITHUB_REF#refs/tags/} + sed "s/\${VERSION}/$VERSION/g" .github/release-template.md > release.md + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + body_path: release.md + overwrite_files: true