chore: release v3.0.2 — toolchain bump, CI sync overhaul, caniuse-lite refresh #174
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: Version Bump and Notify | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| check_commit: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| outputs: | |
| SHOULD_RUN: ${{ steps.check_commit.outputs.SHOULD_RUN }} | |
| steps: | |
| - name: Checkout Files | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
| - name: check if skip ci | |
| id: check_commit | |
| run: | | |
| COMMIT_MESSAGE="${{ github.event.pull_request.title }}" | |
| if [[ "$COMMIT_MESSAGE" == *"[skip ci]"* ]]; then | |
| echo "SHOULD_RUN=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Match is false" | |
| fi | |
| version-bump: | |
| needs: check_commit | |
| if: ${{ needs.check_commit.outputs.SHOULD_RUN != 'false' }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout Source Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Scaffold-Stark/scaffold-stark-2 | |
| token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
| path: source_repo | |
| - name: Checkout Destination Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: Scaffold-Stark/create-stark | |
| token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
| path: destination_repo | |
| - name: Determine version bump type | |
| id: version | |
| run: | | |
| cd source_repo | |
| commit_message=$(git log -1 --pretty=%B) | |
| if [[ "$commit_message" == *"[major]"* ]]; then | |
| echo "type=major" >> "$GITHUB_ENV" | |
| elif [[ "$commit_message" == *"[minor]"* ]]; then | |
| echo "type=minor" >> "$GITHUB_ENV" | |
| elif [[ "$commit_message" == *"[prerelease]"* ]]; then | |
| echo "type=prerelease --preid=rc" >> "$GITHUB_ENV" | |
| elif [[ "$commit_message" == *"[hotfix]"* ]]; then | |
| echo "type=prepatch" >> "$GITHUB_ENV" | |
| else | |
| echo "type=patch" >> "$GITHUB_ENV" | |
| fi | |
| - name: Bump version in Source Repository | |
| id: bump-version-source | |
| run: | | |
| cd source_repo | |
| git pull origin main --no-rebase --strategy=ort --no-edit | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| new_version=$(npm version ${{ env.type }} -m "chore(release): %s [skip ci]") | |
| echo "NEW_VERSION=${new_version}" >> "$GITHUB_ENV" | |
| - name: Copy Files to Destination Repository | |
| run: | | |
| rsync -av --delete \ | |
| --exclude='.git/' \ | |
| --include='.github/' \ | |
| --include='.github/workflows/' \ | |
| --include='.github/workflows/main.yml' \ | |
| --exclude='.github/*' \ | |
| --exclude='.github/workflows/*' \ | |
| --exclude='__test*__' \ | |
| --exclude='CHANGELOG*' \ | |
| --exclude='CONTRIBUTING*' \ | |
| source_repo/ destination_repo/templates/base | |
| cd destination_repo | |
| git add . | |
| git commit -m "chore: sync files from scaffold-stark-2 [skip ci]" | |
| - name: Format .gitignore files | |
| run: | | |
| find destination_repo/templates/base -type f -name ".gitignore" | while read -r gitignore_file; do | |
| mjs_file="${gitignore_file%/*}/.gitignore.template.mjs" | |
| gitignore_content=$(cat "$gitignore_file") | |
| cat > "$mjs_file" <<-EOF | |
| const contents = () => | |
| \`${gitignore_content}\` | |
| export default contents; | |
| EOF | |
| rm "$gitignore_file" | |
| done | |
| cd destination_repo | |
| git add . | |
| git commit -m "chore: convert .gitignore files to .gitignore.template.mjs [skip ci]" | |
| - name: Bump version in Destination Repository | |
| id: bump-version-destination | |
| run: | | |
| cd destination_repo | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| new_version=$(npm version ${{ env.type }} -m "chore(release): %s [skip ci]") | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: "22" | |
| registry-url: "https://registry.npmjs.org/" | |
| - name: Publish release | |
| if: success() | |
| id: publish-release | |
| run: | | |
| cd destination_repo | |
| npm install && npm run build && npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Push Source Repository | |
| if: success() | |
| run: | | |
| cd source_repo | |
| git push origin main --follow-tags | |
| - name: Push Destination Repository | |
| if: success() | |
| run: | | |
| cd destination_repo | |
| git push origin main --follow-tags | |
| - name: Notify Slack on Success | |
| if: success() | |
| uses: slackapi/slack-github-action@v1.26.0 | |
| with: | |
| channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
| slack-message: "GitHub Action succeeded for version bump to ${{ env.NEW_VERSION }}." | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
| - name: Notify Slack on Failure | |
| if: failure() | |
| uses: slackapi/slack-github-action@v1.26.0 | |
| with: | |
| channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
| slack-message: "GitHub Action failed for version bump." | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |