From 73b746402314b94b3b253f7a7ad0059e3a4d4470 Mon Sep 17 00:00:00 2001 From: Nikita Elfimov Date: Mon, 9 Sep 2024 13:27:30 +0300 Subject: [PATCH] fix(github): bump version immediately in publish --- .github/actions/checks/action.yml | 2 +- .github/actions/commit/action.yml | 31 +++++++++------ .github/actions/lint-typecheck/action.yml | 27 ------------- .github/actions/publish-jsr/action.yml | 2 +- .github/actions/publish-npm/action.yml | 2 +- .github/actions/version-apply/action.yaml | 12 ------ .github/actions/version/action.yml | 2 +- .github/workflows/publish.yaml | 6 ++- .github/workflows/version.yaml | 47 ----------------------- 9 files changed, 28 insertions(+), 103 deletions(-) delete mode 100644 .github/actions/lint-typecheck/action.yml delete mode 100644 .github/actions/version-apply/action.yaml delete mode 100644 .github/workflows/version.yaml diff --git a/.github/actions/checks/action.yml b/.github/actions/checks/action.yml index d9b15cc6f..484ab7778 100644 --- a/.github/actions/checks/action.yml +++ b/.github/actions/checks/action.yml @@ -27,4 +27,4 @@ runs: run: | source .env export NODE_OPTIONS - yarn workspaces changed foreach --verbose --topological --no-private dlx jsr publish --dry-run + yarn workspaces changed foreach -vtp --no-private dlx jsr publish --dry-run diff --git a/.github/actions/commit/action.yml b/.github/actions/commit/action.yml index e3951018e..a26230ff8 100644 --- a/.github/actions/commit/action.yml +++ b/.github/actions/commit/action.yml @@ -22,19 +22,28 @@ runs: using: composite steps: - - name: Get GitHub App User ID - id: get-user-id - run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> $GITHUB_OUTPUT - env: - GH_TOKEN: ${{ inputs.GITHUB_TOKEN }} + - name: Compose commit message + id: commit_message + run: | + INITIAL_MESSAGE=$'chore(common): versions\n\n' + temp_file=$(mktemp) + yarn workspaces changed foreach exec "echo \"\$npm_package_name:\$npm_package_version \" >> $temp_file" + MESSAGE=$(cat $temp_file) + echo $(cat $temp_file) + INITIAL_MESSAGE+=$MESSAGE + INITIAL_MESSAGE="${INITIAL_MESSAGE//'%'/' '}" + INITIAL_MESSAGE="${INITIAL_MESSAGE//$'\n'/' '}" + INITIAL_MESSAGE="${INITIAL_MESSAGE//$'\r'/' '}" + echo "commitMessage=$INITIAL_MESSAGE" >> $GITHUB_OUTPUT + echo $INITIAL_MESSAGE + rm $temp_file - name: Commit changes - uses: EndBug/add-and-commit@v9 + uses: planetscale/ghcommit-action@v0.1.44 env: GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} with: - author_name: ${{ steps.get-user-id.outputs.app-slug }} - author_email: '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' - message: ${{ inputs.COMMIT_MESSAGE }} - add: ${{ inputs.PATTERN }} - commit: -S + repo: ${{ github.repository }} + branch: ${{ inputs.BRANCH }} + commit_message: ${{ inputs.COMMIT_MESSAGE }} + file_pattern: ${{ inputs.PATTERN }} diff --git a/.github/actions/lint-typecheck/action.yml b/.github/actions/lint-typecheck/action.yml deleted file mode 100644 index 0781314ff..000000000 --- a/.github/actions/lint-typecheck/action.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Lint and type check composite action - -inputs: - GITHUB_TOKEN: - required: true - -runs: - using: composite - - steps: - - name: Lint - shell: bash - run: | - source .env - export NODE_OPTIONS - yarn checks lint - env: - GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} - - - name: TypeCheck - shell: bash - run: | - source .env - export NODE_OPTIONS - yarn checks typecheck - env: - GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} diff --git a/.github/actions/publish-jsr/action.yml b/.github/actions/publish-jsr/action.yml index a4b0b2114..2b188cf39 100644 --- a/.github/actions/publish-jsr/action.yml +++ b/.github/actions/publish-jsr/action.yml @@ -17,4 +17,4 @@ runs: run: | source .env export NODE_OPTIONS - yarn workspaces changed foreach --verbose --topological --no-private dlx jsr publish + yarn workspaces changed foreach -vtp --no-private dlx jsr publish diff --git a/.github/actions/publish-npm/action.yml b/.github/actions/publish-npm/action.yml index b29fe8251..182a2198a 100644 --- a/.github/actions/publish-npm/action.yml +++ b/.github/actions/publish-npm/action.yml @@ -20,6 +20,6 @@ runs: run: | source .env export NODE_OPTIONS - yarn workspaces changed foreach --verbose --topological --no-private npm publish --access public + yarn workspaces changed foreach -vtp --no-private npm publish --access public env: YARN_NPM_AUTH_TOKEN: ${{ inputs.NPM_TOKEN }} diff --git a/.github/actions/version-apply/action.yaml b/.github/actions/version-apply/action.yaml deleted file mode 100644 index e4db86d2c..000000000 --- a/.github/actions/version-apply/action.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: Apply versions composite action - -runs: - using: composite - - steps: - - name: Version apply - shell: bash - run: | - source .env - export NODE_OPTIONS - yarn version apply --all diff --git a/.github/actions/version/action.yml b/.github/actions/version/action.yml index 1daa8f6b9..2ee384545 100644 --- a/.github/actions/version/action.yml +++ b/.github/actions/version/action.yml @@ -13,6 +13,6 @@ runs: run: | source .env export NODE_OPTIONS - yarn workspaces changed foreach --no-private --verbose version patch --deferred + yarn workspaces changed foreach -tpv --no-private version patch -i env: GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 5423d7288..20f47caa5 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -32,8 +32,10 @@ jobs: - name: Install uses: ./.github/actions/install - - name: Apply versions - uses: ./.github/actions/version-apply + - name: Version + uses: ./.github/actions/version + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish to NPM id: npm diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml deleted file mode 100644 index 0da7abb55..000000000 --- a/.github/workflows/version.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Version - -on: - pull_request: - types: - - closed - branches: - - master - -jobs: - run: - name: Version - env: - NODE_VERSION: '19' - runs-on: ubuntu-latest - permissions: write-all - - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.ATLANTIS_SUPER_BOT_APP_ID }} - private-key: ${{ secrets.ATLANTIS_SUPER_BOT_PRIVATE_KEY }} - - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - - - name: Install - uses: ./.github/actions/install - - - name: Version - uses: ./.github/actions/version - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Commit changes - uses: ./.github/actions/commit - with: - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} - COMMIT_MESSAGE: 'chore(common): versions'