Update .github/workflows/publish-to-chrome.yml #36
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 Drafter | |
| on: | |
| push: | |
| # branches to consider in the event; optional, defaults to all | |
| branches: | |
| - master | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| permissions: | |
| contents: write | |
| jobs: | |
| update_release_draft: | |
| permissions: | |
| # write permission is required to create a github release | |
| contents: write | |
| # write permission is required for autolabeler | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Drafts your next Release notes as Pull Requests are merged into "master" | |
| - name: Draft Release | |
| id: release_drafter | |
| uses: release-drafter/release-drafter@v6 | |
| with: | |
| config-name: release-drafter.yml | |
| publish: false | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| - name: Debug release-drafter outputs | |
| run: | | |
| echo "release-drafter.tag_name='${{ steps.release_drafter.outputs.tag_name }}" | |
| echo "release-drafter.body:"" | |
| echo "${{ steps.release_drafter.outputs.body }}" | |
| - name: Create / prepend CHANGELOG entry | |
| if: steps.release_drafter.outputs.tag_name != '' | |
| run: | | |
| TAG="${{ steps.release_drafter.outputs.tag_name }}" | |
| BODY="${{ steps.release_drafter.outputs.body }}" | |
| DATE="$(date +%F)" | |
| printf "## %s - %s\n\n%s\n\n---\n\n" "$TAG" "$DATE" "$BODY" > /tmp/new_changelog.md | |
| if [ -f CHANGELOG.md ]; then | |
| cat CHANGELOG.md >> /tmp/new_changelog.md | |
| fi | |
| mv /tmp/new_changelog.md CHANGELOG.md | |
| git status --porcelain | |
| - name: Commit CHANGELOG, create & push tag | |
| if: steps.release_drafter.outputs.tag_name != '' | |
| env: | |
| TAG: ${{ steps.release_drafter.outputs.tag_name }} | |
| GIT_AUTHOR_NAME: "github-actions[bot]" | |
| GIT_AUTHOR_EMAIL: "github-actions[bot]@users.noreply.github.com" | |
| run: | | |
| git config user.name "$GIT_AUTHOR_NAME" | |
| git config user.email "$GIT_AUTHOR_EMAIL" | |
| git add CHANGELOG.md || true | |
| if git diff --cached --quiet; then | |
| echo "No CHANGELOG.md changes to commit" | |
| else | |
| git commit -m "docs(changelog): update for ${TAG}" | |
| git push origin HEAD:master | |
| fi | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag ${TAG} already exists locally" | |
| else | |
| git tag -a "${TAG}" -m "Release ${TAG}" | |
| fi | |
| git push origin "refs/tags/${TAG}" || echo "Tag push failed or tag already exists remotely" | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Ensure correct branch is checked out (only on PR) | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "Checking out PR source branch: ${{ github.head_ref }}" | |
| git fetch origin ${{ github.head_ref }} | |
| git checkout ${{ github.head_ref }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Update Changelog | |
| run: | | |
| VERSION="${{ steps.release_drafter.outputs.tag_name }}" | |
| BODY="${{ steps.release_drafter.outputs.body }}" | |
| # Create a new changelog entry file | |
| echo -e "## ${VERSION} ($(date +'%Y-%m-%d'))\n\n${BODY}\n\n" > new_changelog_entry.md | |
| # Prepend the new entry to the existing CHANGELOG.md | |
| if [ -f CHANGELOG.md ]; then | |
| cat CHANGELOG.md >> new_changelog_entry.md | |
| fi | |
| mv new_changelog_entry.md CHANGELOG.md | |
| # Commits the updated CHANGELOG.md and creates a tag for the new version | |
| - name: Commit and Push Changelog | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: 'docs: Update CHANGELOG.md for ${{ steps.release_drafter.outputs.tag_name }}' | |
| file_pattern: 'CHANGELOG.md' | |
| tagging_message: ${{ steps.release_drafter.outputs.tag_name }} | |