diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml deleted file mode 100644 index 5ebff58..0000000 --- a/.github/workflows/canary.yml +++ /dev/null @@ -1,57 +0,0 @@ -# Adjust according to your needs -name: Release Canary - -on: - issue_comment: - types: - - created - -permissions: - id-token: write - contents: write - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -jobs: - canary: - if: ${{ github.event.issue.pull_request && (github.event.comment.body == 'canary-publish' || github.event.comment.body == '/canary-publish')}} - runs-on: ubuntu-latest - steps: - - name: Get PR branch name - id: get_branch - run: | - PR=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.issue.pull_request.url }}) - echo "::set-output name=branch::$(echo $PR | jq -r '.head.ref')" - - - uses: actions/checkout@v4 - with: - ref: ${{ steps.get_branch.outputs.branch }} - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 - with: - node-version: '22' - 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: Install Dependencies - run: pnpm install --frozen-lockfile - - - name: Build - run: pnpm build - - - name: Canary Publish - uses: NaverPayDev/changeset-actions/canary-publish@main - with: - github_token: ${{ secrets.ACTION_TOKEN }} # Add user PAT if necessary - npm_tag: canary # Specify the npm tag to use for deployment - publish_script: pnpm run release:canary # Script to execute Canary deployment - packages_dir: packages # Directory of packages to detect changes (default: packages,share) - excludes: '.turbo,.github' # Files or directories to exclude from change detection - version_template: '{VERSION}-canary.{DATE}-{COMMITID7}' diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml deleted file mode 100644 index 3acaf88..0000000 --- a/.github/workflows/rc.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Adjust according to your needs -name: Release RC - -on: - issue_comment: - types: - - created - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -permissions: - id-token: write - contents: write # to create release - -jobs: - canary: - if: ${{ github.event.issue.pull_request && (github.event.comment.body == 'rc-publish' || github.event.comment.body == '/rc-publish')}} - runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Get PR branch name - id: get_branch - run: | - PR=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.issue.pull_request.url }}) - echo "::set-output name=branch::$(echo $PR | jq -r '.head.ref')" - - - uses: actions/checkout@v4 - with: - ref: ${{ steps.get_branch.outputs.branch }} - fetch-depth: 0 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 - with: - node-version: '22' - 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: Install Dependencies - run: pnpm install --frozen-lockfile - - - name: Build - run: pnpm build - - - name: RC Publish - uses: NaverPayDev/changeset-actions/canary-publish@main - with: - github_token: ${{ secrets.ACTION_TOKEN }} # Add user PAT if necessary - npm_tag: rc # Specify the npm tag to use for deployment - publish_script: pnpm run release:canary # Script to execute Canary deployment - packages_dir: packages # Directory of packages to detect changes (default: packages,share) - excludes: '.turbo,.github' # Files or directories to exclude from change detection - version_template: '{VERSION}-rc.{DATE}-{COMMITID7}' - create_release: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9114c9e..b41f32b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,12 @@ -name: release packages +name: Publish Package on: push: branches: - main + issue_comment: + types: + - created permissions: id-token: write @@ -12,13 +15,32 @@ permissions: concurrency: ${{ github.workflow }}-${{ github.ref }} 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: name: Release runs-on: ubuntu-latest + needs: [get-branch] + if: | + always() && + (github.event_name == 'push' || + (github.event_name == 'issue_comment' && needs.get-branch.result == 'success')) steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: + ref: ${{ needs.get-branch.outputs.branch || github.ref }} token: ${{ secrets.ACTION_TOKEN }} fetch-depth: 0 @@ -43,7 +65,8 @@ jobs: - name: Build run: pnpm build - - name: Create Release Pull Request + - name: Publish - Release + if: github.event_name == 'push' id: changesets uses: NaverPayDev/changeset-actions/publish@main with: @@ -57,3 +80,28 @@ jobs: formatting_script: pnpm run markdownlint:fix env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} + + - name: 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}' + + - name: 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 }}