diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..1b6f99c --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,63 @@ +name: Create release + +on: + workflow_dispatch: + inputs: + bump: + description: "Version bump type" + required: true + type: choice + options: + - patch + - minor + - major + +permissions: + contents: write + +jobs: + release: + name: Create tag and release + runs-on: ubuntu-latest + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.RIOTBYTE_BOT_APP_ID }} + private-key: ${{ secrets.RIOTBYTE_BOT_PRIVATE_KEY }} + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Determine next version + id: version + run: | + LATEST=$(git tag --list --sort=-v:refname '[0-9]*.[0-9]*.[0-9]*' --merged HEAD | head -n1) + + if [ -z "$LATEST" ]; then + LATEST="0.0.0" + fi + + IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST" + + case "${{ inputs.bump }}" in + major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; + minor) MINOR=$((MINOR + 1)); PATCH=0 ;; + patch) PATCH=$((PATCH + 1)) ;; + esac + + NEXT="${MAJOR}.${MINOR}.${PATCH}" + echo "previous=${LATEST}" >> "$GITHUB_OUTPUT" + echo "next=${NEXT}" >> "$GITHUB_OUTPUT" + echo "Bumping ${LATEST} → ${NEXT} (${{ inputs.bump }})" + + - name: Create tag and GitHub release + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + gh release create "${{ steps.version.outputs.next }}" \ + --target "${{ github.sha }}" \ + --title "${{ steps.version.outputs.next }}" \ + --generate-notes \ + --notes-start-tag "${{ steps.version.outputs.previous }}" diff --git a/.github/workflows/deploy-client.yml b/.github/workflows/deploy-client.yml new file mode 100644 index 0000000..6fa29a9 --- /dev/null +++ b/.github/workflows/deploy-client.yml @@ -0,0 +1,40 @@ +name: Deploy client to Cloudflare Pages + +on: + push: + tags: + - "*.*.*" + +jobs: + deploy: + name: Build and deploy SPA + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: latest + + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build client + env: + VITE_SERVER_URL: https://cv-generator-api.riotbyte.com + run: pnpm --filter @cv/client build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy apps/client/dist --project-name=cv-generator diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0a94e26 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Build and publish Docker images + +on: + push: + tags: + - "*.*.*" + +env: + REGISTRY: ghcr.io + IMAGE_BASE: ghcr.io/riotbyte-com/cv-generator + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + strategy: + matrix: + include: + - name: server + dockerfile: .docker/server.Dockerfile + - name: worker + dockerfile: .docker/worker.Dockerfile + + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ env.IMAGE_BASE }}-${{ matrix.name }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=ref,event=tag + + - uses: docker/build-push-action@v6 + with: + context: . + file: ${{ matrix.dockerfile }} + target: production + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}