Merge pull request #95 from backstage/fix/recipe-aifixup-and-workspac… #52
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: release | |
| permissions: | |
| id-token: write | |
| contents: write | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| outputs: | |
| changed_dirs: ${{ steps.tag.outputs.changed_dirs }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Get Yarn cache path | |
| id: yarn-cache | |
| run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: ${{ steps.yarn-cache.outputs.dir }} | |
| key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| yarn-${{ runner.os }}- | |
| - run: yarn install --immutable | |
| - name: Check for pending changesets | |
| id: check | |
| run: | | |
| changeset_files=$(find .changeset -name '*.md' ! -name 'README.md' 2>/dev/null || true) | |
| if [ -z "$changeset_files" ]; then | |
| echo "No pending changesets found. Skipping release." | |
| echo "has_changesets=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Pending changesets found:" | |
| echo "$changeset_files" | |
| echo "has_changesets=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Version packages | |
| if: steps.check.outputs.has_changesets == 'true' | |
| run: yarn version-packages | |
| - name: Check for version changes | |
| if: steps.check.outputs.has_changesets == 'true' | |
| id: diff | |
| run: | | |
| if git diff --quiet; then | |
| echo "No version changes produced. Skipping commit." | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit version bumps | |
| if: steps.diff.outputs.has_changes == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Version Packages" | |
| - name: Push to main | |
| if: steps.diff.outputs.has_changes == 'true' | |
| run: | | |
| git pull --rebase origin main | |
| git push origin main | |
| - name: Tag released versions | |
| if: steps.diff.outputs.has_changes == 'true' | |
| id: tag | |
| run: bash scripts/tag-and-publish.sh | |
| publish: | |
| name: Publish ${{ matrix.dir }} | |
| needs: release | |
| if: needs.release.outputs.changed_dirs != '[]' && needs.release.outputs.changed_dirs != '' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| dir: ${{ fromJson(needs.release.outputs.changed_dirs) }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: main | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Get Yarn cache path | |
| id: yarn-cache | |
| run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: ${{ steps.yarn-cache.outputs.dir }} | |
| key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} | |
| restore-keys: | | |
| yarn-${{ runner.os }}- | |
| - run: yarn install --immutable | |
| - name: Publish codemod | |
| uses: codemod/publish-action@dd6c8dbc5ceb1a6146feba41481d88b43da50024 # v1 | |
| with: | |
| path: ${{ matrix.dir }} |