diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 0000000..40ac71a --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,34 @@ +name: Init Release +on: + workflow_dispatch: + inputs: + TARGET_VERSION: + description: 'TARGET_VERSION to build manifests (e.g. 2.5.0-rc1) Note: the `v` prefix is not used' + required: true + type: string + +jobs: + init-release: + name: Create new release for ${{ inputs.TARGET_VERSION }} + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: main + + - name: Check if TARGET_VERSION is well formed. + run: | + set -xue + # Target version must not contain 'v' prefix + if echo "${{ inputs.TARGET_VERSION }}" | grep -e '^v'; then + echo "::error::Target version '${{ inputs.TARGET_VERSION }}' should not begin with a 'v' prefix, refusing to continue." >&2 + exit 1 + fi + + - name: Create release + run: | + gh release create v${{ inputs.TARGET_VERSION }} --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/push-docker.yaml b/.github/workflows/push-docker.yaml index 71c1c30..36280de 100644 --- a/.github/workflows/push-docker.yaml +++ b/.github/workflows/push-docker.yaml @@ -1,16 +1,15 @@ name: Deploy Images to GHCR on: - push: - tags: - - "v*.*.*" + workflow_run: + workflows: [Init Release] + types: + - completed jobs: push-image: + if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest - defaults: - run: - working-directory: "./azure-clientid-syncer" steps: - name: "Checkout GitHub Action" uses: actions/checkout@main @@ -23,7 +22,9 @@ jobs: password: ${{secrets.GITHUB_TOKEN}} - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + run: echo "RELEASE_VERSION=$(gh release view --jq '.name[1:]' --json name)" >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v5 diff --git a/.github/workflows/push-helm.yaml b/.github/workflows/push-helm.yaml new file mode 100644 index 0000000..e79cd43 --- /dev/null +++ b/.github/workflows/push-helm.yaml @@ -0,0 +1,37 @@ +name: Release Charts + +on: + workflow_run: + workflows: [Init Release] + types: + - completed + +jobs: + release: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Replace version + run: | + RELEASE_VERSION=$(gh release view --jq '.name[1:]' --json name) + cd charts/azure-clientid-syncer-webhook + sed -i "s@version:.*@version: $RELEASE_VERSION@g" Chart.yaml + sed -i "s@appVersion:.*@appVersion: $RELEASE_VERSION@g" Chart.yaml + cat Chart.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.5.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/charts/azure-clientid-syncer-webhook/Chart.yaml b/charts/azure-clientid-syncer-webhook/Chart.yaml index c657e43..4eec54f 100644 --- a/charts/azure-clientid-syncer-webhook/Chart.yaml +++ b/charts/azure-clientid-syncer-webhook/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: azure-clientid-syncer-webhook description: A Helm chart to install the azure-clientid-syncer webhook type: application -version: 0.0.1 -appVersion: 0.0.1 +version: 0.0.0 +appVersion: 0.0.0 home: https://github.com/shiftavenue/azure-clientid-syncer sources: - https://github.com/shiftavenue/azure-clientid-syncer \ No newline at end of file diff --git a/go.mod b/go.mod index 8e8bcf8..2944ab2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/shiftavenue/aks-clientid-syncer +module github.com/shiftavenue/azure-clientid-syncer go 1.21.5