Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/templates/preview-build-comment.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!-- preview-build -->
## 📦 v${VERSION} Preview Build

Release Please가 다음 릴리즈를 준비 중입니다: **v${VERSION}** (commit `${SHORT_SHA}`).
이 PR이 머지되면 정식 릴리즈가 자동으로 생성됩니다. 머지 전에 아래 미리보기 바이너리로 새 버전을 검증할 수 있습니다.

> [!IMPORTANT]
> 이 바이너리는 **공식 릴리즈가 아닙니다.** GitHub Actions Artifact는 약 **14일 후 자동 삭제**되며 다운로드에는 GitHub 로그인이 필요합니다.

### 다운로드

**옵션 A — GitHub CLI (권장)**

```bash
gh run download ${RUN_ID} \
--repo ${REPO} \
--name ${ARTIFACT_NAME} \
--dir solactl-preview
cd solactl-preview
```

**옵션 B — 웹 브라우저**

[Workflow Run #${RUN_ID}](${RUN_URL}) 페이지 하단 _Artifacts_ 섹션에서 [`${ARTIFACT_NAME}`](${ARTIFACT_URL}) 을 받아 압축을 풉니다. 다운로드 받은 zip 안에는 OS/아키텍처별 tarball·zip 과 `checksums.txt` 가 들어 있습니다.

### 실행

#### Linux / macOS

플랫폼에 맞는 tarball을 풉니다 (`<OS>` = `linux` 또는 `darwin`, `<ARCH>` = `amd64` 또는 `arm64`):

```bash
tar -xzf solactl_${VERSION}-preview-${SHORT_SHA}_<OS>_<ARCH>.tar.gz
chmod +x solactl
./solactl version
# 예상 출력: solactl ${VERSION}-preview-${SHORT_SHA} (commit: ..., date: ...)
```

> [!NOTE]
> macOS에서 _"확인되지 않은 개발자"_ 경고가 뜨면 quarantine 속성을 제거하세요:
> ```bash
> xattr -d com.apple.quarantine ./solactl
> ```

#### Windows

```powershell
Expand-Archive solactl_${VERSION}-preview-${SHORT_SHA}_windows_amd64.zip -DestinationPath .
.\solactl_${VERSION}-preview-${SHORT_SHA}_windows_amd64\solactl.exe version
Comment on lines +48 to +49
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Windows 가이드에서 Expand-Archive 명령을 -DestinationPath .와 함께 사용하면 압축 파일 내의 파일들이 현재 디렉토리에 바로 풀립니다. 현재 .goreleaser.yaml 설정상 압축 파일 내부에 별도의 디렉토리 구조(wrap_in_directory)가 없으므로, solactl.exe는 현재 위치에 생성됩니다. 따라서 하위 디렉토리 경로를 포함한 실행 명령은 실패하게 됩니다. 실행 경로를 .\solactl.exe로 수정하는 것이 좋습니다.

Expand-Archive solactl_${VERSION}-preview-${SHORT_SHA}_windows_amd64.zip -DestinationPath .
.\solactl.exe version

```

### 무결성 검증 (선택)

```bash
sha256sum -c checksums.txt --ignore-missing
```

### 검증 포인트

머지 전에 아래 항목들을 확인해 주세요:

- 이 PR 상단의 _Release notes_ 에 나열된 변경 사항이 의도대로 동작하는지
- `solactl version` 출력이 위 예상 출력과 일치하는지
- 회귀 가능성이 있는 기존 명령들 (`solactl configure`, `solactl send sms`, `solactl quota`, `solactl kakao` 등)
- 자주 쓰는 워크플로 (설정 파일 생성·로드, `--profile` 전환, `--debug` 출력)

문제가 있다면 이 PR에 코멘트로 알려주세요. 머지 후 release 워크플로가 자동으로 정식 바이너리를 빌드·배포합니다.

---

<sub>이 댓글은 <code>.github/workflows/release-please.yml</code> 의 <code>preview-release-pr</code> job 에 의해 자동으로 생성·갱신됩니다 · build commit <code>${SHA}</code> · run [#${RUN_ID}](${RUN_URL})</sub>
135 changes: 135 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,141 @@ jobs:
gh api "repos/$REPO/statuses/$SHA" \
-f state=failure -f context="Lint" -f description="Lint failed"

preview-release-pr:
name: Preview Build (Release PR)
needs: release-please
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
runs-on: ubuntu-latest
env:
ARTIFACT_NAME_PREFIX: solactl-preview
steps:
- name: Set pending status
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=pending -f context="Preview Build" -f description="Building preview binaries..."

- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.pr_head_sha }}
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.1'

- name: Resolve preview version
id: version
run: |
VERSION=$(jq -r '."."' .release-please-manifest.json)
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
echo "::error::Failed to read version from .release-please-manifest.json"
exit 1
fi
SHORT_SHA="${GITHUB_SHA::7}"
TAG="v${VERSION}-preview-${SHORT_SHA}"
ARTIFACT_NAME="${ARTIFACT_NAME_PREFIX}-v${VERSION}-${SHORT_SHA}"
{
echo "version=${VERSION}"
echo "short_sha=${SHORT_SHA}"
echo "tag=${TAG}"
echo "artifact_name=${ARTIFACT_NAME}"
} >> "$GITHUB_OUTPUT"
echo "GORELEASER_CURRENT_TAG=${TAG}" >> "$GITHUB_ENV"

- name: Run GoReleaser snapshot
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: release --snapshot --skip=publish --clean

- name: Upload preview artifacts
id: artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.version.outputs.artifact_name }}
path: |
dist/solactl_*.tar.gz
dist/solactl_*.zip
dist/checksums.txt
retention-days: 14
if-no-files-found: error
compression-level: 0

- name: Comment preview guide on PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
VERSION: ${{ steps.version.outputs.version }}
SHORT_SHA: ${{ steps.version.outputs.short_sha }}
TAG: ${{ steps.version.outputs.tag }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
ARTIFACT_URL: ${{ steps.artifact.outputs.artifact-url }}
ARTIFACT_NAME: ${{ steps.version.outputs.artifact_name }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
TEMPLATE_PATH: .github/templates/preview-build-comment.md.tmpl
run: |
set -euo pipefail

if [ ! -f "$TEMPLATE_PATH" ]; then
echo "::error::Comment template not found at $TEMPLATE_PATH"
exit 1
fi

PR_NUMBER=$(gh pr list --repo "$REPO" --head release-please--branches--main --state open --json number --jq '.[0].number')
if [ -z "$PR_NUMBER" ]; then
echo "::warning::No open release-please PR found; skipping comment"
exit 0
fi

export VERSION SHORT_SHA TAG SHA ARTIFACT_NAME ARTIFACT_URL RUN_ID RUN_URL REPO

BODY_FILE="$(mktemp)"
envsubst '${VERSION} ${SHORT_SHA} ${TAG} ${SHA} ${ARTIFACT_NAME} ${ARTIFACT_URL} ${RUN_ID} ${RUN_URL} ${REPO}' \
< "$TEMPLATE_PATH" > "$BODY_FILE"

PAYLOAD_FILE="$(mktemp)"
jq -Rs '{body: .}' "$BODY_FILE" > "$PAYLOAD_FILE"

EXISTING_ID=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \
--jq '.[] | select(.body | startswith("<!-- preview-build -->")) | .id' | head -n 1)

if [ -n "$EXISTING_ID" ]; then
echo "Updating existing preview comment $EXISTING_ID on PR #$PR_NUMBER"
gh api -X PATCH "repos/$REPO/issues/comments/$EXISTING_ID" --input "$PAYLOAD_FILE" > /dev/null
else
echo "Creating new preview comment on PR #$PR_NUMBER"
gh api "repos/$REPO/issues/$PR_NUMBER/comments" --input "$PAYLOAD_FILE" > /dev/null
fi

- name: Report success
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=success -f context="Preview Build" -f description="Preview binaries ready"

- name: Report failure
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=failure -f context="Preview Build" -f description="Preview build failed"

goreleaser:
name: Release Binaries
needs: release-please
Expand Down
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ archives:
checksum:
name_template: checksums.txt

snapshot:
version_template: '{{ .Version }}'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

snapshot.version_template'{{ .Version }}'으로 설정하면 GoReleaser의 기본 스냅샷 버전 규칙(보통 {{ .Tag }}-next)이 사용됩니다. 가이드 템플릿(.github/templates/preview-build-comment.md.tmpl)에서 안내하는 ${VERSION}-preview-${SHORT_SHA} 형식과 바이너리 버전 및 파일명을 일치시키려면 템플릿을 명시적으로 지정하는 것이 좋습니다.

  version_template: '{{ .Version }}-preview-{{ .ShortCommit }}'


changelog:
disable: true

Expand Down