From 605414a1ecb8cfb20e32e1dae87bdeadf121f2c7 Mon Sep 17 00:00:00 2001 From: relusc Date: Thu, 4 Apr 2024 10:43:54 +0200 Subject: [PATCH] add label workflow --- .github/workflows/git_tag.yml | 40 +++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/.github/workflows/git_tag.yml b/.github/workflows/git_tag.yml index 0de111f..13b91b7 100644 --- a/.github/workflows/git_tag.yml +++ b/.github/workflows/git_tag.yml @@ -1,4 +1,4 @@ -name: Build image +name: Determine and create tag on: pull_request: @@ -8,18 +8,46 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - build-image: + determine-create-tag: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 + - name: Get latest tag + id: get-latest-tag shell: bash run: | - latest=$(git describe --abbrev=0 --tags || echo "v0.0.0") - echo "LATEST_TAG=latest" >> "$GITHUB_OUTPUT" + tag=$(git describe --abbrev=0 --tags) + if [ "$?" -ne "0" ] + then + tag="v0.0.0" + fi + echo "tag=$latest" >> "$GITHUB_OUTPUT" + - name: Get PR labels id: pr-labels uses: joerick/pr-labels-action@v1.0.9 - - if: contains(steps.pr-labels.outputs.labels, 'new patch release') - run: echo '### New version 🚀\n When merging, version xyz will be created' >> $GITHUB_STEP_SUMMARY + + - name: Get semver bump level + id: get-semver-level + run: | + level="patch" + all_labels=(${{ steps.pr-labels.outputs.labels }}) + if [[ ${all_labels[@]} =~ "new minor release" ]] + then + level="minor" + elif [[ ${all_labels[@]} =~ "new major release" ]] + then + level="major" + fi + echo "level=$level" >> "$GITHUB_OUTPUT" + + - uses: actions-ecosystem/action-bump-semver@v1 + id: bump-semver + with: + current_version: ${{ steps.get-latest-tag.outputs.tag }} + level: ${{ steps.get-semver-level.outputs.level }} + + - name: Print summary + run: echo '### New version 🚀\n When merging, version ${{ steps.bump-semver.outputs.new_version }} will be created' >> $GITHUB_STEP_SUMMARY