Skip to content

test/ bump

test/ bump #23

name: Update Version
on:
pull_request:
types:
- closed
jobs:
validate_version:
if: github.event.pull_request.merged && github.base_ref == 'main'
runs-on: ubuntu-latest
outputs:
head_ref: ${{ steps.comment-branch.outputs.head_ref }}
prev_version: ${{ steps.get-version.outputs.prev_version }}
full_version: ${{ steps.get-version.outputs.full_version }}
major_version: ${{ steps.get-version.outputs.major_version }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Get version
id: get-version
run: |
base_sha=${{ github.event.pull_request.base.sha }}
git fetch origin $base_sha
prev_version=$(git show ${base_sha}:pubspec.yaml | grep 'version:' | cut -d ':' -f2 | sed 's/ //' | cut -d'+' -f1)
echo "prev_version=$prev_version" >> $GITHUB_OUTPUT
full_version=$(cat pubspec.yaml | grep 'version' | cut -d ':' -f2 | sed 's/ //' | cut -d'+' -f1)
echo "full_version=$full_version" >> $GITHUB_OUTPUT
major_version=$(echo "$full_version" | cut -d'.' -f1)
echo "major_version=$major_version" >> $GITHUB_OUTPUT
publish_tags:
needs: validate_version
if: needs.validate_version.outputs.prev_version != needs.validate_version.outputs.full_version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Tag new target
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"
git tag -f v${{ needs.validate_version.outputs.full_version }} -m $'${{ github.event.pull_request.title }}'
git tag -f v${{ needs.validate_version.outputs.major_version }} -m $'${{ github.event.pull_request.title }}'
- name: Push new tag
run: |
git push -f origin v${{ needs.validate_version.outputs.full_version }}
git push -f origin v${{ needs.validate_version.outputs.major_version }}