docs #91
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: Bump & Tag | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'release' | |
permissions: | |
contents: read | |
jobs: | |
check-committer: | |
runs-on: ubuntu-latest | |
outputs: | |
should_run: ${{ steps.check.outputs.should_run }} | |
steps: | |
- id: check | |
env: | |
AUTHOR_EMAIL: ${{ github.event.commits[0].author.email }} | |
run: | | |
# Allow dependabot emails specifically | |
if [[ "$AUTHOR_EMAIL" == *"dependabot[bot]@users.noreply.github.com"* ]]; then | |
echo "should_run=true" >> $GITHUB_OUTPUT | |
# Skip other noreply emails | |
elif [[ "$AUTHOR_EMAIL" == *"@users.noreply.github.com"* ]]; then | |
echo "should_run=false" >> $GITHUB_OUTPUT | |
# Allow all other emails | |
else | |
echo "should_run=true" >> $GITHUB_OUTPUT | |
fi | |
bump-version: | |
name: 'Bump Version or Tag' | |
needs: check-committer | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
newTag: ${{ steps.bump.outputs.newTag }} | |
if: ${{ needs.check-committer.outputs.should_run == 'true' }} | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.BUILD_APP_ID }} | |
private-key: ${{ secrets.BUILD_PRIVATE_KEY }} | |
- name: 'Checkout source code' | |
uses: 'actions/checkout@v2' | |
with: | |
ref: ${{ github.ref }} | |
token: ${{ steps.app-token.outputs.token }} | |
- name: 'Automated Version Bump' | |
id: bump | |
uses: 'phips28/gh-action-bump-version@master' | |
with: | |
version-type: ${{ github.ref == 'refs/heads/release' && 'minor' || '' }} | |
commit-message: 'chore: bumps version to {{version}}' | |
bump-policy: 'ignore' | |
skip-push: 'true' | |
- 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: ${{ steps.app-token.outputs.token }} | |
- run: | | |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | |
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' | |
- name: 'Create Tags and package version' | |
run: | | |
git push --follow-tags | |
git push --tags | |
sonarqube: | |
name: 'Sonar Qube Scan' | |
needs: check-committer | |
runs-on: ubuntu-latest | |
if: ${{ needs.check-committer.outputs.should_run == 'true' && github.ref == 'refs/heads/main' }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Run NPM coverage | |
uses: anna-money/github-actions-npm@master | |
with: | |
target: 'test:coverage' | |
- name: SonarQube Scan | |
uses: SonarSource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
hacs-validation: | |
name: 'HACS Validation' | |
needs: check-committer | |
runs-on: 'ubuntu-latest' | |
if: ${{ needs.check-committer.outputs.should_run == 'true' }} | |
steps: | |
- name: 'Checkout the repository' | |
uses: 'actions/checkout@v4' | |
- name: 'Run HACS validation' | |
uses: 'hacs/action@main' | |
with: | |
category: 'plugin' | |
create-release: | |
name: 'Create Release' | |
needs: bump-version | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
if: github.ref == 'refs/heads/release' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Run NPM build | |
uses: anna-money/github-actions-npm@master | |
with: | |
target: 'build' | |
- uses: johnyherangi/create-release-notes@main | |
id: create-release-notes | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Get Last PR Title | |
id: get-pr-title | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
PR_TITLE=$(gh api graphql -f query=' | |
query { | |
repository(owner: "${{ github.repository_owner }}", name: "${{ github.event.repository.name }}") { | |
commit: object(expression: "${{ github.sha }}") { | |
... on Commit { | |
associatedPullRequests(first: 1) { | |
edges { | |
node { | |
title | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
' --jq '.data.repository.commit.associatedPullRequests.edges[0].node.title') | |
echo "pr_title=$PR_TITLE" >> $GITHUB_OUTPUT | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: 'dist/**' | |
generateReleaseNotes: true | |
tag: ${{ needs.bump-version.outputs.newTag }} | |
body: ${{ steps.create-release-notes.outputs.release-notes }} | |
name: '${{ needs.bump-version.outputs.newTag }} - ${{ steps.get-pr-title.outputs.pr_title }}' | |
update-main: | |
name: 'Update main branch with release changes' | |
needs: bump-version | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
if: github.ref == 'refs/heads/release' | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.BUILD_APP_ID }} | |
private-key: ${{ secrets.BUILD_PRIVATE_KEY }} | |
- name: 'Checkout source code' | |
uses: 'actions/checkout@v2' | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
fetch-depth: 0 | |
ref: main | |
- 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: ${{ steps.app-token.outputs.token }} | |
- run: | | |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | |
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' | |
- name: Merge release into main | |
run: | | |
git fetch origin release | |
git merge origin/release | |
git push origin main |