Skip to content

release

release #26

Workflow file for this run

name: release
# d-party モノレポ root の release ワークフローから統一バージョンを受け取って起動される。
# package.json の version を書き換えて main へコミットし、タグ + GitHub Release を作る。
on:
workflow_dispatch:
inputs:
version:
description: "Release version (X.Y.Z)"
required: true
type: string
release_note:
description: "Release notes (optional)"
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Bump version and commit
env:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
# version 行のみを置換してフォーマット差分を最小化する
node -e "const fs=require('fs');let s=fs.readFileSync('package.json','utf8');s=s.replace(/(\"version\"\s*:\s*\")[^\"]*(\")/, '\$1'+process.env.VERSION+'\$2');fs.writeFileSync('package.json',s);"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json
if git diff --cached --quiet; then
echo "package.json already at v${VERSION}; skipping bump commit"
else
git commit -m "chore: bump version to v${VERSION} [skip ci]"
git push origin HEAD:main
fi
- name: Force-update release tag
env:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
git tag -f "v${VERSION}"
git push origin "refs/tags/v${VERSION}" --force
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
name: Release v${{ inputs.version }}
body: ${{ inputs.release_note }}
generate_release_notes: true
target_commitish: main
# release ジョブが push した `vX.Y.Z` タグの commit を native arm64 でビルドし、
# GHCR(public) へ push する(prod-kube / Argo CD の配信元)。NEXT_PUBLIC_* は
# 渡さない(prod-kube はブラウザ origin から接続先を導出する)。compose-prod は
# 引き続き build.args で焼くため本ジョブの影響を受けない。初回 push 後に GHCR
# Package を一度だけ Public にすること。
build-push:
needs: release
runs-on: ubuntu-24.04-arm # native arm64 (no QEMU)
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: true
# version 入力からタグを直接組み立てる(git タグと完全一致・`v` 付き)。
tags: ghcr.io/d-party/frontend:v${{ inputs.version }}