From 1e88db24630dc6facc274d189d69ab062568ad27 Mon Sep 17 00:00:00 2001 From: Jimi Dodd-o Date: Wed, 4 Dec 2024 14:46:58 -0500 Subject: [PATCH] Chore/add automated release or update of major GHA version (#60) * Initial commit * Use head * Automated update or releasing of major GHA versions * Give perms * Fetch depth * GH Token * Typo * Needs tag * Update name of step * Update .github/workflows/create-update-release.yaml Co-authored-by: Mitchell Nielsen --------- Co-authored-by: Mitchell Nielsen --- .github/workflows/create-update-release.yaml | 32 ++++++++++++++++++++ README.md | 3 ++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/create-update-release.yaml diff --git a/.github/workflows/create-update-release.yaml b/.github/workflows/create-update-release.yaml new file mode 100644 index 0000000..d60265d --- /dev/null +++ b/.github/workflows/create-update-release.yaml @@ -0,0 +1,32 @@ +--- +name: Update Major Version of Prefect Deploy Action +on: + push: + tags: + # Match the version format to not catch vx major releases + - 'v*.*.*' +permissions: {} +jobs: + update-create-major-version: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Release or Update Major Version + run: | + export MAJOR_VERSION=$(echo ${{ github.ref_name }} | cut -d '.' -f 1) + echo "Releasing major version ${MAJOR_VERSION}" + if git show-ref --tags --verify --quiet "refs/tags/${MAJOR_VERSION}"; then + echo "Tag ${MAJOR_VERSION} exists, bumping to match with the latest release" + git tag ${MAJOR_VERSION} -f + git push origin ${MAJOR_VERSION} -f + else + echo "Tag ${MAJOR_VERSION} does not exist. Creating a new tag and release." + export RELEASE_SHA=$(git rev-parse HEAD) + gh release create "${MAJOR_VERSION}" --title "${MAJOR_VERSION}" --generate-notes --target "${RELEASE_SHA}" --latest + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 493df1a..bc36574 100644 --- a/README.md +++ b/README.md @@ -196,5 +196,8 @@ jobs: PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }} ``` +## Releasing the Action +Manually create a new semver release (i.e `v1.0.0`) against a new tag to trigger the release workflow. This workflow will update the major version of the action (i.e `v1`) to point to the new semver release. + ## Terms & Conditions See here for the Prefect's [Terms and Conditions](https://www.prefect.io/legal/terms/).