From 44abfa4566ff54704beef3cb0b4722049043eed3 Mon Sep 17 00:00:00 2001 From: anpigon Date: Fri, 15 Nov 2024 22:06:49 +0900 Subject: [PATCH] chore(release.yml): add environment variable for GITHUB_TOKEN and improve release workflow with cache and validation steps perf(release.yml): optimize release notes generation and add file existence check to ensure build success --- .github/workflows/release.yml | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3391530..19bc5c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,9 +7,8 @@ on: permissions: contents: write - -env: - GH_TOKEN: ${{ github.token }} + issues: write # Release 노트 작성을 위해 + pull-requests: write # Release 관련 PR 필요시 jobs: build: @@ -30,19 +29,40 @@ jobs: with: node-version-file: '.nvmrc' + - name: Cache pnpm modules + id: pnpm-cache # use this to check for `cache-hit` ==> if: steps.pnpm-cache.outputs.cache-hit != 'true' + uses: actions/cache@v4 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + - name: Install dependencies + if: steps.pnpm-cache.outputs.cache-hit != 'true' run: pnpm install - name: Build plugin run: pnpm run build + continue-on-error: false - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - tag="${GITHUB_REF#refs/tags/}" \ - - git log $(git describe --tags --abbrev=0)..HEAD --oneline > release-notes.md \ - + tag="${GITHUB_REF#refs/tags/}" + git log "$(git describe --tags --abbrev=0)"..HEAD --oneline > release-notes.md + + # 파일 존재 확인 + files=("manifest.json" "main.js" "styles.css") + for file in "${files[@]}"; do + if [ ! -f "$file" ]; then + echo "Error: 빌드 결과물 '$file'을 찾을 수 없습니다. 빌드 단계가 성공적으로 완료되었는지 확인해주세요." + exit 1 + fi + done + gh release create "$tag" \ - --title="$tag" \ + --title="Release $tag" \ --notes-file="release-notes.md" \ manifest.json build/main.js build/styles.css