FixSendEmail_hanging_job #37
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: Tagging And Release | |
on: | |
pull_request: | |
types: | |
- closed | |
permissions: {} | |
jobs: | |
tagging-and-release: | |
if: github.event.pull_request.merged == true && github.base_ref == 'trunk' && github.head_ref == 'changeset-release/trunk' | |
permissions: | |
contents: write # to create release (changesets/action) | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# This makes action fetch all Git history so that Changesets can generate changelogs with the correct commits | |
fetch-depth: 0 | |
- name: Set git user | |
run: | | |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" | |
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18.18.2" | |
- name: Install dependencies | |
run: | | |
npm i -g [email protected] | |
pnpm install -r --ignore-scripts | |
- name: Get tag version | |
id: get-tag-version | |
run: | | |
VERSION=$(cat ./apps/reaction/package.json | grep -m 1 version | sed 's/[^0-9.]//g') | |
REACTION_APP_NEW_TAG=v$VERSION | |
echo "REACTION_APP_NEW_TAG=$REACTION_APP_NEW_TAG" >> $GITHUB_ENV | |
echo '::set-output name=newTag::'$REACTION_APP_NEW_TAG | |
echo '::set-output name=version::'$VERSION | |
echo "New release tag is $REACTION_APP_NEW_TAG" | |
- name: Check should create release | |
id: should-create-tag | |
run: | | |
if [ $(git tag -l "$REACTION_APP_NEW_TAG") ]; then | |
echo '::set-output name=REACTION_APP_TAG_EXISTS::true' | |
else | |
echo '::set-output name=REACTION_APP_TAG_EXISTS::false' | |
fi | |
- name: Release apps and packages | |
if: steps.should-create-tag.outputs.REACTION_APP_TAG_EXISTS == 'false' | |
uses: changesets/action@v1 | |
with: | |
publish: pnpm changeset tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract release notes | |
if: steps.should-create-tag.outputs.REACTION_APP_TAG_EXISTS == 'false' | |
id: extract-release-notes | |
uses: cardinalby/git-get-release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: "reaction@${{ steps.get-tag-version.outputs.version }}" | |
doNotFailIfNotFound: true | |
- name: Create tag | |
if: steps.extract-release-notes.outputs.body != '' | |
run: | | |
git tag -a $REACTION_APP_NEW_TAG -m "chore(release): $REACTION_APP_NEW_TAG [skip ci]" | |
git push origin $REACTION_APP_NEW_TAG | |
echo "Create tag success: $REACTION_APP_NEW_TAG" | |
- name: Create Release | |
if: steps.extract-release-notes.outputs.body != '' | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: ${{ steps.extract-release-notes.outputs.body }} | |
tag_name: ${{ steps.get-tag-version.outputs.newTag }} | |
draft: false | |
prerelease: false |