Merge pull request #277 from trydofor/changeset-release/develop #405
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: Auto Test/Bump/Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| name: Auto Test/Bump/Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| checks: write | |
| steps: | |
| - name: Checkout ${{ github.ref_name }} | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # https://pnpm.io/continuous-integration#github-actions | |
| - name: Setup pnpm by packageManager | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup nodejs by .nvmrc | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: Prepare Project | |
| run: | | |
| chmod a+x .changeset/*.sh | |
| echo "install pnpm-hoist-layer to devDep" | |
| pnpm -w i --no-frozen-lockfile | |
| echo "reset the ci lockfile" | |
| git restore pnpm-lock.yaml | |
| echo "install all deps by lockfile" | |
| pnpm i --frozen-lockfile | |
| # https://github.com/changesets/action | |
| cat > "$HOME/.npmrc" << EOF | |
| //registry.npmjs.org/:_authToken=$NPM_TOKEN | |
| EOF | |
| echo "## Project Version" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Name | Version |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|---------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| $(jq -r '.name' package.json) | $(jq -r '.version' package.json) |" >> $GITHUB_STEP_SUMMARY | |
| echo "| node | $(node -v) |" >> $GITHUB_STEP_SUMMARY | |
| echo "| pnpm | $(pnpm -v) |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Test and Coverage | |
| run: | | |
| pnpm dev:test | |
| - name: Common Coverage | |
| uses: davelosert/vitest-coverage-report-action@v2 | |
| with: | |
| working-directory: './layers/common' | |
| - name: Mobile Coverage | |
| uses: davelosert/vitest-coverage-report-action@v2 | |
| with: | |
| working-directory: './layers/mobile' | |
| - name: Calculate Version | |
| id: version-may | |
| run: | | |
| git fetch origin main:main | |
| git branch --show-current | |
| echo "may_version=$(.changeset/version-may.sh)" >> $GITHUB_OUTPUT | |
| - name: Changeset Auto | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| commit: ":bookmark: bumping versions to ${{ steps.version-may.outputs.may_version }}" | |
| title: ":rocket: release versions ${{ steps.version-may.outputs.may_version }}" | |
| version: .changeset/version-top.sh | |
| publish: .changeset/publish-all.sh | |
| createGithubReleases: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Changeset Status | |
| if: steps.changesets.outputs.published == 'true' || steps.changesets.outputs.hasChangesets == 'true' | |
| run: | | |
| echo "## Changeset Status" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Status | Value |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| Published | ${{ steps.changesets.outputs.published }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| Changeset | ${{ steps.changesets.outputs.hasChangesets }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| PR Number | ${{ steps.changesets.outputs.pullRequestNumber }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| - name: Github Release | |
| id: release | |
| if: steps.changesets.outputs.published == 'true' | |
| uses: halvardssm/[email protected] | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| path: "./package.json" | |
| - name: Publish Status | |
| if: steps.changesets.outputs.published == 'true' | |
| run: | | |
| echo "## Publish Status" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Package | Version |" >> $GITHUB_STEP_SUMMARY | |
| echo "|-----------|---------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| $(jq -r '.name' package.json) | $(jq -r '.version' package.json) |" >> $GITHUB_STEP_SUMMARY | |
| # Format published packages | |
| publishedPackages='${{ steps.changesets.outputs.publishedPackages }}' | |
| echo "$publishedPackages" | jq -c '.[]' | while read pkg; do | |
| echo "| $(echo $pkg | jq -r '.name') | $(echo $pkg | jq -r '.version') |" >> $GITHUB_STEP_SUMMARY | |
| done | |
| echo "" >> $GITHUB_STEP_SUMMARY |