From 8b7b011a9590ad71130b234f6a1dc0463de39e47 Mon Sep 17 00:00:00 2001 From: Leo Ribeiro Date: Fri, 23 Feb 2024 15:02:46 -0500 Subject: [PATCH] automated release bump wip --- .github/workflows/release.yml | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ddc16d1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release + +on: + workflow_dispatch: + inputs: + versionType: + description: "Version Type - Major, Minor, Patch, Manual" + required: true + default: "Patch" + type: choice + options: + - major + - minor + - patch + - manual + customVersion: + description: "Custom Version - Use if Version Type is Manual" + required: false + +jobs: + release: + # validate if input was versionType = Major, Minor, Patch or Manual + # if its Manual we require the `customVersion` value + if: github.event.inputs.versionType != 'manual' || github.event.inputs.customVersion != null + + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Bump tag version + id: bump_version + run: | + VERSION_TYPE=${{ github.event.inputs.versionType }} + CUSTOM_VERSION=${{ github.event.inputs.customVersion }} + if [[ "$VERSION_TYPE" == "manual" && -n "$CUSTOM_VERSION" ]]; then + NEW_TAG=$CUSTOM_VERSION + elif [[ "$VERSION_TYPE" == "major" || "$VERSION_TYPE" == "minor" || "$VERSION_TYPE" == "patch" ]]; then + npm install -g semver + LAST_TAG=$(git describe --match "[0-9]*.[0-9]*.[0-9]*" --tags --abbrev=0) + NEW_TAG=$(semver -i $VERSION_TYPE $LAST_TAG) + else + echo "Invalid version type" + exit 1 + fi + echo "New version: $NEW_TAG" + echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT