Merge pull request #46 from NaverPayDev/commit-helper/README #47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release packages | |
on: | |
push: | |
branches: | |
- main | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
permissions: | |
contents: write # to create release | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
published: ${{ steps.changesets.outputs.published }} | |
commithelperGoWillBePublished: ${{ steps.checkCommitHelperGo.outputs.commithelperGoWillBePublished }} | |
packageVersion: ${{ steps.getPackageVersion.outputs.packageVersion }} | |
env: | |
SKIP_COMMIT_HELPER_POSTINSTALL: 1 | |
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: checkoutRepo | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.ACTION_TOKEN }} | |
fetch-depth: 0 | |
- name: setupGo | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.24' | |
- name: useNodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: installCorepack | |
run: npm install -g [email protected] | |
- name: enableCorepack | |
run: corepack enable | |
- name: installDependencies | |
run: pnpm install --frozen-lockfile | |
- name: checkIfCommitHelperGoWasPublished | |
id: checkCommitHelperGo | |
run: | | |
packageVersion=$(cat packages/commithelper-go/package.json | jq -r '.version') | |
npmInfo=$(npm info @naverpay/commithelper-go@$packageVersion --json >/dev/null 2>&1 && npm info @naverpay/commithelper-go@$packageVersion --json 2>/dev/null || echo "{}") | |
isValidJson=$(echo "$npmInfo" | jq empty > /dev/null 2>&1 && echo "true" || echo "false") | |
if [ "$isValidJson" = "true" ]; then | |
isPublished=$(echo "$npmInfo" | jq -r 'if .error then "false" else "true" end') | |
else | |
isPublished="false" | |
fi | |
if [ "$isPublished" = "false" ]; then | |
echo "commithelperGoWillBePublished=false" >> $GITHUB_OUTPUT | |
else | |
echo "commithelperGoWillBePublished=true" >> $GITHUB_OUTPUT | |
fi | |
- name: getPackageVersion | |
id: getPackageVersion | |
run: | | |
packageVersion=$(cat packages/commithelper-go/package.json | jq -r '.version') | |
echo "packageVersion=$packageVersion" >> $GITHUB_OUTPUT | |
- name: buildNodePackages | |
run: pnpm build | |
- name: createReleasePullRequestOrPublishToNpm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
title: '🚀 version changed packages' | |
commit: '📦 bump changed packages version' | |
publish: pnpm release | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
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 |