Skip to content

Merge pull request #50 from NaverPayDev/feature/49 #73

Merge pull request #50 from NaverPayDev/feature/49

Merge pull request #50 from NaverPayDev/feature/49 #73

Workflow file for this run

name: release packages
on:
push:
branches:
- main
issue_comment:
types:
- created
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write
contents: write
jobs:
get-branch:
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && (github.event.comment.body == 'canary-publish' || github.event.comment.body == '/canary-publish' || github.event.comment.body == 'rc-publish' || github.event.comment.body == '/rc-publish')
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.get_branch.outputs.branch }}
steps:
- name: Get PR branch name
id: get_branch
run: |
PR=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.issue.pull_request.url }})
branch=$(echo "$PR" | jq -r '.head.ref')
echo "branch=$branch" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
needs: [get-branch]
if: |
always() &&
(github.event_name == 'push' ||
(github.event_name == 'issue_comment' && needs.get-branch.result == 'success'))
outputs:
published: ${{ steps.publish_release.outputs.published || steps.publish_canary.outputs.published || steps.publish_rc.outputs.published }}
commithelperGoWillBePublished: ${{ steps.checkCommitHelperGo.outputs.commithelperGoWillBePublished }}
packageVersion: ${{ steps.checkCommitHelperGo.outputs.publishedVersion || steps.getCommitHelperGoVersion.outputs.packageVersion }}
env:
SKIP_COMMIT_HELPER_POSTINSTALL: 1
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: checkoutRepo
uses: actions/checkout@v4
with:
ref: ${{ needs.get-branch.outputs.branch || github.ref }}
token: ${{ secrets.ACTION_TOKEN }}
fetch-depth: 0
- name: setupGo
uses: actions/setup-go@v4
with:
go-version: '1.24'
- uses: pnpm/action-setup@v4
- name: useNodeJs
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'pnpm'
- name: Check and upgrade npm
run: |
echo "Current npm version:"
npm --version
npm install -g npm@latest
echo "Upgraded npm version:"
npm --version
- name: installDependencies
run: pnpm install --frozen-lockfile
- name: getCommitHelperGoVersion
id: getCommitHelperGoVersion
run: |
packageVersion=$(cat packages/commithelper-go/package.json | jq -r '.version')
echo "packageVersion=$packageVersion" >> $GITHUB_OUTPUT
- name: buildNodePackages
run: pnpm build
- name: Publish - Release
id: publish_release
if: github.event_name == 'push'
uses: NaverPayDev/changeset-actions/publish@main
with:
github_token: ${{ secrets.ACTION_TOKEN }}
git_username: npayfebot
git_email: npay.fe.bot@navercorp.com
publish_script: pnpm release
pr_title: '🚀 version changed packages'
commit_message: '📦 bump changed packages version'
create_github_release_tag: true
formatting_script: pnpm run markdownlint:fix
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}
- name: Publish - Canary
id: publish_canary
if: github.event_name == 'issue_comment' && (github.event.comment.body == 'canary-publish' || github.event.comment.body == '/canary-publish')
uses: NaverPayDev/changeset-actions/canary-publish@main
with:
github_token: ${{ secrets.ACTION_TOKEN }}
npm_tag: canary
publish_script: pnpm run release:canary
packages_dir: 'packages'
excludes: '.turbo,.github'
version_template: '{VERSION}-canary.{DATE}-{COMMITID7}'
create_release: true
- name: Publish - RC
id: publish_rc
if: github.event_name == 'issue_comment' && (github.event.comment.body == 'rc-publish' || github.event.comment.body == '/rc-publish')
uses: NaverPayDev/changeset-actions/canary-publish@main
with:
github_token: ${{ secrets.ACTION_TOKEN }}
npm_tag: rc
publish_script: pnpm run release:canary
packages_dir: 'packages'
excludes: '.turbo,.github'
version_template: '{VERSION}-rc.{DATE}-{COMMITID7}'
create_release: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if commithelper-go was published
id: checkCommitHelperGo
if: always()
run: |
publishedPackages='${{ steps.publish_release.outputs.publishedPackages || steps.publish_canary.outputs.publishedPackages || steps.publish_rc.outputs.publishedPackages }}'
if [ -z "$publishedPackages" ] || [ "$publishedPackages" == "null" ]; then
echo "commithelperGoWillBePublished=false" >> $GITHUB_OUTPUT
else
commithelperGo=$(echo "$publishedPackages" | jq -r '.[] | select(.name == "@naverpay/commithelper-go")')
if [ -n "$commithelperGo" ] && [ "$commithelperGo" != "null" ]; then
echo "commithelperGoWillBePublished=true" >> $GITHUB_OUTPUT
# Extract the actual published version (handles canary/RC versions)
version=$(echo "$commithelperGo" | jq -r '.version')
echo "publishedVersion=$version" >> $GITHUB_OUTPUT
else
echo "commithelperGoWillBePublished=false" >> $GITHUB_OUTPUT
fi
fi
upload-assets:
needs: release
if: needs.release.outputs.published == 'true' && needs.release.outputs.commithelperGoWillBePublished == 'true'
uses: ./.github/workflows/release-asset.yaml
with:
package: '@naverpay/commithelper-go'
version: ${{ needs.release.outputs.packageVersion }}
secrets: inherit