ci: release workflow #20
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: Create Release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get new tag version | |
id: newtag | |
run: | | |
echo ::set-output name=NEW_TAG::$(node -e "console.log(require('./package.json').version)") | |
- name: Generate release notes and changelog | |
id: releasenotes | |
run: | | |
LAST_TAG=$(git describe --tags --abbrev=0) | |
NEW_TAG=$(node -e "console.log(require('./package.json').version)") | |
CHANGELOG=$(git log --pretty=format:"%h - %s (%an)" $LAST_TAG..HEAD) | |
RELEASE_NOTES="**Full Changelog**: https://github.com/${{ github.repository }}/compare/$LAST_TAG...$NEW_TAG" | |
echo ::set-outout name=RELEASE_NOTES::$RELEASE_NOTES | |
- name: Create new tag | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.RN_BOILERPLATE }} | |
script: | | |
const newTag = `refs/tags/${{ steps.newtag.outputs.NEW_TAG }}`; | |
github.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: newTag, | |
sha: context.sha | |
}); | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.RN_BOILERPLATE }} | |
with: | |
tag_name: ${{ steps.newtag.outputs.NEW_TAG }} | |
release_name: ${{ steps.newtag.outputs.NEW_TAG }} | |
body: ${{ steps.releasenotes.outputs.RELEASE_NOTES }} | |
draft: false | |
prerelease: false |