From d87ebd57fa2fbe72211c342f7eb68c098a8d0c61 Mon Sep 17 00:00:00 2001 From: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:45:42 -0400 Subject: [PATCH 1/2] release --- .github/workflows/build.yaml | 15 ++++++---- .github/workflows/release.yaml | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 541bfc1..d3e2f62 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,6 +8,11 @@ on: branches: - main types: [ opened, synchronize, reopened ] + workflow_call: + inputs: + tag: + type: string + default: 'latest' permissions: contents: read @@ -33,18 +38,18 @@ jobs: with: context: . push: ${{ github.event_name == 'push' }} - tags: crenshawdotdev/argocd-executor-plugin:latest + tags: crenshawdotdev/argocd-executor-plugin:${{ inputs.tag }} - name: Install cosign uses: sigstore/cosign-installer@main with: cosign-release: 'v1.13.0' - if: ${{ github.event_name == 'push' }} - - name: Sign latest image + if: ${{ github.event_name == 'push' || github.event_name == 'workflow_call' }} + - name: Sign ${{ inputs.tag }} image run: | - cosign sign --key env://COSIGN_PRIVATE_KEY crenshawdotdev/argocd-executor-plugin:latest + cosign sign --key env://COSIGN_PRIVATE_KEY crenshawdotdev/argocd-executor-plugin:${{ inputs.tag }} # Displays the public key to share. cosign public-key --key env://COSIGN_PRIVATE_KEY env: COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}} COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}} - if: ${{ github.event_name == 'push' }} + if: ${{ github.event_name == 'push' || github.event_name == 'workflow_call' }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ba1f47f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,51 @@ +name: Create argocd-executor-plugin release +on: + workflow_dispatch: + inputs: + tag: + required: true + +permissions: + contents: read + +jobs: + build-and-push: + uses: crenshaw-dev/argocd-executor-plugin/.github/workflows/build.yaml@main + with: + tag: ${{ github.event.inputs.tag }} + if: github.repository == 'crenshaw-dev/argocd-executor-plugin' + prepare-release: + permissions: + contents: write # To push changes to release branch + name: Release + if: github.repository == 'crenshaw-dev/argocd-executor-plugin' + runs-on: ubuntu-22.04 + env: + GIT_USERNAME: crenshaw-dev + GIT_EMAIL: 350466+crenshaw-dev@users.noreply.github.com + RELEASE_TAG: ${{ github.event.inputs.tag }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Push release tag + run: | + set -ue + + git config --global user.email "${GIT_EMAIL}" + git config --global user.name "${GIT_USERNAME}" + + git tag ${RELEASE_TAG} + git push origin ${RELEASE_TAG} + + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: ${{ env.RELEASE_TAG }} + tag_name: ${{ env.RELEASE_TAG }} + generate_release_notes: true From ebfce0142b8bd41d215cb871aaa2c19e6341434f Mon Sep 17 00:00:00 2001 From: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:49:37 -0400 Subject: [PATCH 2/2] release improvements --- .github/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d3e2f62..656730d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,7 +12,7 @@ on: inputs: tag: type: string - default: 'latest' + required: true permissions: contents: read @@ -31,14 +31,14 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: crenshawdotdev password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push uses: docker/build-push-action@v3 with: context: . push: ${{ github.event_name == 'push' }} - tags: crenshawdotdev/argocd-executor-plugin:${{ inputs.tag }} + tags: crenshawdotdev/argocd-executor-plugin:${{ inputs.tag || 'latest' }} - name: Install cosign uses: sigstore/cosign-installer@main with: