From 2b97819839ca9c5a7c0480b277d7781bfaf99c41 Mon Sep 17 00:00:00 2001 From: Alexandru Claudius Virtopeanu Date: Mon, 25 Nov 2024 10:52:28 +0200 Subject: [PATCH 1/3] feat: add upbound release workflow --- .github/workflows/release-upbound.yml | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/release-upbound.yml diff --git a/.github/workflows/release-upbound.yml b/.github/workflows/release-upbound.yml new file mode 100644 index 00000000..c92ffc34 --- /dev/null +++ b/.github/workflows/release-upbound.yml @@ -0,0 +1,44 @@ +name: Release Crossplane Provider + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + version_tag: + description: 'The version tag to publish (e.g., v1.1.6)' + required: true + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Upbound CLI + run: | + curl -sL https://cli.upbound.io | sh + echo "::add-path::${HOME}/.upbound/bin" + + - name: Login to Upbound + env: + UP_API_KEY: ${{ secrets.UP_API_KEY }} + run: up login --api-key $UP_API_KEY + + - name: Set version tag + if: github.event_name == 'push' + id: version + run: echo "VERSION_TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV + + - name: Set manual version tag + if: github.event_name == 'workflow_dispatch' + id: manual_version + run: echo "VERSION_TAG=${{ github.event.inputs.version_tag }}" >> $GITHUB_ENV + + - name: Build and push Crossplane provider + run: | + up xpkg build --name provider-ionoscloud.xpkg + up xpkg push xpkg.upbound.io/ionos-cloud/provider-ionoscloud:${VERSION_TAG} -f provider-ionoscloud.xpkg From 552526d61aaa932216592c7a216f32614897a4fe Mon Sep 17 00:00:00 2001 From: Alexandru Claudius Virtopeanu Date: Mon, 25 Nov 2024 11:18:58 +0200 Subject: [PATCH 2/3] upbound release should depend on CD --- .github/workflows/release-upbound.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-upbound.yml b/.github/workflows/release-upbound.yml index c92ffc34..d0cbf3e5 100644 --- a/.github/workflows/release-upbound.yml +++ b/.github/workflows/release-upbound.yml @@ -1,9 +1,11 @@ name: Release Crossplane Provider on: - push: - tags: - - 'v*' + workflow_run: + workflows: + - CD + types: + - completed workflow_dispatch: inputs: version_tag: @@ -28,14 +30,13 @@ jobs: UP_API_KEY: ${{ secrets.UP_API_KEY }} run: up login --api-key $UP_API_KEY - - name: Set version tag - if: github.event_name == 'push' - id: version - run: echo "VERSION_TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV + - name: Set version tag for workflow_run + if: github.event_name == 'workflow_run' + run: | + echo "VERSION_TAG=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV - - name: Set manual version tag + - name: Set version tag for workflow_dispatch if: github.event_name == 'workflow_dispatch' - id: manual_version run: echo "VERSION_TAG=${{ github.event.inputs.version_tag }}" >> $GITHUB_ENV - name: Build and push Crossplane provider From 1847524de0bbee863b5ac2e069cb4172dbcafbc7 Mon Sep 17 00:00:00 2001 From: Alexandru Claudius Virtopeanu Date: Mon, 25 Nov 2024 12:04:49 +0200 Subject: [PATCH 3/3] add regex safeguard for semver tags --- .github/workflows/release-upbound.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-upbound.yml b/.github/workflows/release-upbound.yml index d0cbf3e5..b0029dfb 100644 --- a/.github/workflows/release-upbound.yml +++ b/.github/workflows/release-upbound.yml @@ -33,7 +33,14 @@ jobs: - name: Set version tag for workflow_run if: github.event_name == 'workflow_run' run: | - echo "VERSION_TAG=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV + VERSION_TAG=${{ github.event.workflow_run.head_branch }} + + if [[ ! "$VERSION_TAG" =~ ^v[0-9]+(\.[0-9]+)?(\.[0-9]+)?(-[a-zA-Z0-9]+(\.[0-9]+)?)?$ ]]; then + echo "Invalid tag format: $VERSION_TAG. Expected a semantic versioning tag (e.g., v1, v1.0.0, v1.0.0-beta, v1.0.0-rc.2)." + exit 1 + fi + + echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV - name: Set version tag for workflow_dispatch if: github.event_name == 'workflow_dispatch'