Bump version to release #56
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: Bump version to release | |
on: | |
workflow_dispatch: | |
inputs: | |
MAJOR_OR_MINOR: | |
type: choice | |
description: major/minor release | |
options: | |
- minor | |
- major | |
default: minor | |
required: true | |
VERSION_NAME: | |
type: string | |
description: major version name | |
default: '' | |
jobs: | |
bump_version: | |
name: Bump version and tag for release | |
runs-on: ubuntu-latest | |
env: | |
GIT_USERNAME: ${{ github.actor }} | |
GIT_USEREMAIL: "${{ github.actor }}@endlessos.org" | |
outputs: | |
tagname: ${{ steps.have_new_tagname.outputs.tagname }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Need to fetch everything so that 'git describe' can see the tags | |
fetch-depth: 0 | |
- name: Set up Git environment | |
run: | | |
git config --global user.name $GIT_USERNAME | |
git config --global user.email $GIT_USEREMAIL | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
# Should be same version as in scripts/bootstrap.sh | |
node-version: '16.14.0' | |
- name: Install latest pipenv | |
run: | | |
python -m pip install --upgrade pipenv wheel | |
- name: Install dependencies in pipenv | |
run: | | |
bash ./scripts/bootstrap.sh --ci | |
- name: Bump minor version | |
if: ${{ inputs.MAJOR_OR_MINOR != 'major' }} | |
run: | | |
pipenv run yarn bump-version minor | |
- name: Bump major version | |
if: ${{ inputs.MAJOR_OR_MINOR == 'major' }} | |
run: | | |
if [ ${{ inputs.VERSION_NAME }} = '' ] | |
then | |
echo "Inputs' VERSION_NAME must be set with a non-empty string" | |
exit 22 | |
fi | |
pipenv run yarn bump-version major ${{ inputs.VERSION_NAME }} | |
- name: Push bump commit & tag to stable branch | |
id: have_new_tagname | |
run: | | |
git show | |
tagname=$(git describe --always --tags --match 'v*') | |
git push origin ${{ github.ref_name }} $tagname | |
echo "tagname=$tagname" >> $GITHUB_OUTPUT | |
release: | |
# Using the GITHUB_TOKEN in a workflow will not create a new workflow run to | |
# prevent from accidentally creating recursive workflow runs. So, call the | |
# following workflow here and inherit the secrets by design. | |
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow | |
name: Release | |
needs: bump_version | |
if: startsWith(needs.bump_version.outputs.tagname, 'v') | |
uses: ./.github/workflows/release.yml | |
with: | |
tagname: ${{ needs.bump_version.outputs.tagname }} | |
secrets: inherit |