chore: Update README.md #66
Workflow file for this run
This file contains 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: | |
pull_request: | |
branches: | |
- main | |
- master | |
types: [ closed ] | |
workflow_dispatch: # force release | |
jobs: | |
check: | |
permissions: | |
contents: read | |
runs-on: ubuntu-latest | |
# when release PR is merged or workflow_dispatch is triggered, run this job | |
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' | |
outputs: | |
EXISTS_TAG: ${{ steps.tag_check.outputs.EXISTS_TAG }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set PACKAGE_VERSION | |
run: echo "PACKAGE_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV | |
- name: Tag Check | |
id: tag_check | |
run: | | |
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG_NAME}" | |
http_status_code=$( | |
curl -sLI \ | |
-w '%{http_code}' \ | |
-o /dev/null \ | |
$GET_API_URL \ | |
) | |
if [ "$http_status_code" -ne "404" ] ; then | |
echo "EXISTS_TAG=true" >> $GITHUB_OUTPUT | |
else | |
echo "EXISTS_TAG=false" >> $GITHUB_OUTPUT | |
fi | |
env: | |
TAG_NAME: v${{ env.PACKAGE_VERSION }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
release: | |
needs: check | |
runs-on: ubuntu-latest | |
if: (!cancelled() && (needs.check.outputs.EXISTS_TAG == 'false')) | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set PACKAGE_VERSION | |
run: echo "PACKAGE_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV | |
- name: Git Identity | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Git Tag | |
uses: pkgdeps/git-tag-action@v3 | |
with: | |
version: ${{ env.PACKAGE_VERSION }} | |
github_token: ${{ secrets.GH_PAT }} | |
github_repo: ${{ github.repository }} | |
git_commit_sha: ${{ github.sha }} | |
git_tag_prefix: "v" | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
with: | |
tag_name: v${{ env.PACKAGE_VERSION }} | |
# Copy Pull Request's tile and body to Release Note | |
name: ${{ github.event.pull_request.title }} | |
body: ${{ github.event.pull_request.body }} | |
draft: false | |
prerelease: false | |
generate_release_notes: ${{ !github.event.pull_request.body }} | |
- uses: actions/github-script@v7 | |
if: github.event_name != 'workflow_dispatch' | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '🎉 Release https://github.com/${{ github.repository }}/releases/tag/v${{ env.PACKAGE_VERSION }}' | |
}) |