metanorma/metanorma-cli #342
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-tag | |
on: | |
repository_dispatch: | |
types: [ metanorma/metanorma-cli ] | |
workflow_dispatch: | |
inputs: | |
next_version: | |
description: | | |
Next version. Should correspond to the released metanorma-cli gem | |
required: true | |
jobs: | |
push-tag: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' || github.event.client_payload.ref != 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }} | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.1' | |
- run: | | |
git config --global user.name "metanorma-ci" | |
git config --global user.email "[email protected]" | |
- if: github.event_name == 'repository_dispatch' | |
name: Parse metanorma-cli version (repository_dispatch) | |
env: | |
METANORMA_CLI_TAG: ${{ github.event.client_payload.ref }} | |
run: | | |
echo METANORMA_CLI_VERSION=${METANORMA_CLI_TAG#*/v} >> ${GITHUB_ENV} | |
- if: github.event_name == 'workflow_dispatch' | |
name: Parse metanorma-cli version (workflow_dispatch) | |
run: | | |
echo METANORMA_CLI_VERSION=${{ github.event.inputs.next_version }} >> ${GITHUB_ENV} | |
- name: Docker tag version | |
run: | | |
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/main/gemver-to-semver.rb && chmod +x gemver-to-semver.rb | |
echo "DOCKER_TAG=$(./gemver-to-semver.rb --strip-prefix ${METANORMA_CLI_VERSION})" >> $GITHUB_ENV | |
- uses: rubenesp87/[email protected] | |
with: | |
version: ${{ env.DOCKER_TAG }} | |
- name: Update version | |
run: | | |
echo "IMAGE_VERSION := ${METANORMA_CLI_VERSION}" > VERSION.mak | |
pushd metanorma-ruby | |
bundle remove metanorma-cli | |
bundle add metanorma-cli -v ${METANORMA_CLI_VERSION} | |
popd | |
- name: Push commit and tag | |
run: | | |
git add VERSION.mak metanorma-ruby/Gemfile | |
git commit -m "Bump version to ${DOCKER_TAG}" | |
git tag v${DOCKER_TAG} | |
git push origin HEAD:${GITHUB_REF} --tags |