From 02c54ce272bda990ea528106eebc205e7286d877 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Thu, 31 Oct 2024 09:31:47 +0100 Subject: [PATCH 01/58] Start refactor for verifier --- .github/workflows/initial_release.yml | 33 ++++--------- .github/workflows/release_trigger.yml | 36 +++++---------- .github/workflows/verify_secrets.yml | 46 +++++++++++++++++++ .../addon_repo_initial_release.yml | 2 +- .../addon_repo_release_trigger.yml | 2 +- 5 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/verify_secrets.yml diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index a50c992..bfb7295 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -35,33 +35,18 @@ env: REQUIRED_VARS: MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME jobs: - verify_repo_vars_and_secrets: - runs-on: ubuntu-latest - - # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) - # TODO only check if no inputs provided - # TODO move verification into github action - steps: - - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} - if: ${{ !env.GH_TOKEN }} - run: | - echo "::error::Secret 'GH_TOKEN' is not set or empty" - - - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} - if: ${{ !env.GH_USER }} - run: | - echo "::error::Secret 'GH_USER' is not set or empty" + verify_repo_secrets: + uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@refactor-release-workflow-structure + secrets: + gh_token: ${{ env.GH_TOKEN }} + gh_user: ${{ env.GH_USER }} + gh_mail: ${{ env.GH_EMAIL }} - - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} - if: ${{ !env.GH_EMAIL }} - run: | - echo "::error::Secret 'GH_EMAIL' is not set or empty" - - name: 🔎 Secrets verified - if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} - run: | - echo "::notice::All required secrets are present." + verify-repo-vars: + runs-on: ubuntu-latest + steps: - name: 🔎 Verify repo variables for ${{ github.repository }} run: | missing_vars=$(echo ${{ env.REQUIRED_VARS }} | tr ',' '\n' | while read var; do diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 89eba7e..db04f66 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -31,33 +31,18 @@ env: CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" jobs: - verify_repo_vars_and_secrets: - runs-on: ubuntu-latest - - # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) - # TODO move verification into github action - # TODO RnD more efficient way for secret checks without converting them to values - steps: - - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} - if: ${{ !env.GH_TOKEN }} - run: | - echo "::error::Secret 'GH_TOKEN' is not set or empty" - - - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} - if: ${{ !env.GH_USER }} - run: | - echo "::error::Secret 'GH_USER' is not set or empty" + verify-repo-secrets: + uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure + secrets: + gh_token: ${{ env.GH_TOKEN }} + gh_user: ${{ env.GH_USER }} + gh_mail: ${{ env.GH_EMAIL }} - - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} - if: ${{ !env.GH_EMAIL }} - run: | - echo "::error::Secret 'GH_EMAIL' is not set or empty" - - name: 🔎 Secrets verified - if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} - run: | - echo "::notice::All required secrets are present." + verify-repo-vars: + runs-on: ubuntu-latest + steps: - name: 🔎 Verify repo variables for ${{ github.repository }} run: | missing_vars=$(echo ${{ env.REQUIRED_VARS }} | tr ',' '\n' | while read var; do @@ -76,7 +61,8 @@ jobs: get-latest-release: runs-on: ubuntu-latest needs: - - verify_repo_vars_and_secrets + - verify-repo-secrets + - verify-repo-vars outputs: id: ${{ steps.latest-release.outputs.id }} name: ${{ steps.latest-release.outputs.name }} diff --git a/.github/workflows/verify_secrets.yml b/.github/workflows/verify_secrets.yml new file mode 100644 index 0000000..8e26dc4 --- /dev/null +++ b/.github/workflows/verify_secrets.yml @@ -0,0 +1,46 @@ +name: Verify repository secrets + +on: + workflow_call: + secrets: + gh_token: + required: true + gh_user: + required: true + gh_mail: + required: true + +env: + GH_TOKEN: ${{ secrets.gh_token || false }} + GH_USER: ${{ secrets.gh_user || false }} + GH_EMAIL: ${{ secrets.gh_mail || false }} + +jobs: + verify_secrets: + + runs-on: ubuntu-latest + + # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) + # TODO only check if no inputs provided + # TODO move verification into github action + + steps: + - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} + if: ${{ !env.GH_TOKEN }} + run: | + echo "::error::Secret 'GH_TOKEN' is not set or empty" + + - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} + if: ${{ !env.GH_USER }} + run: | + echo "::error::Secret 'GH_USER' is not set or empty" + + - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} + if: ${{ !env.GH_EMAIL }} + run: | + echo "::error::Secret 'GH_EMAIL' is not set or empty" + + - name: 🔎 Secrets verified + if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} + run: | + echo "::notice::All required secrets are present." \ No newline at end of file diff --git a/caller_workflows/addon_repo_initial_release.yml b/caller_workflows/addon_repo_initial_release.yml index 1e225bb..f011ef5 100644 --- a/caller_workflows/addon_repo_initial_release.yml +++ b/caller_workflows/addon_repo_initial_release.yml @@ -11,7 +11,7 @@ on: jobs: call-release-trigger: - uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@develop + uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@refactor-release-workflow-structure with: draft: ${{ inputs.draft }} secrets: diff --git a/caller_workflows/addon_repo_release_trigger.yml b/caller_workflows/addon_repo_release_trigger.yml index caa1075..2d2d3a6 100644 --- a/caller_workflows/addon_repo_release_trigger.yml +++ b/caller_workflows/addon_repo_release_trigger.yml @@ -15,7 +15,7 @@ on: jobs: call-release-trigger: - uses: ynput/ops-repo-automation/.github/workflows/release_trigger.yml@develop + uses: ynput/ops-repo-automation/.github/workflows/release_trigger.yml@refactor-release-workflow-structure with: draft: ${{ inputs.draft }} release_overwrite: ${{ inputs.release_overwrite }} From 4d9f8b1533c639de4c14a22d02aa96c7714e2242 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Thu, 31 Oct 2024 09:31:47 +0100 Subject: [PATCH 02/58] Start refactor for verifier --- .github/workflows/initial_release.yml | 33 ++++++------------- .github/workflows/release_trigger.yml | 36 +++++++-------------- .github/workflows/verify_secrets.yml | 46 +++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/verify_secrets.yml diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index a50c992..bfb7295 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -35,33 +35,18 @@ env: REQUIRED_VARS: MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME jobs: - verify_repo_vars_and_secrets: - runs-on: ubuntu-latest - - # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) - # TODO only check if no inputs provided - # TODO move verification into github action - steps: - - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} - if: ${{ !env.GH_TOKEN }} - run: | - echo "::error::Secret 'GH_TOKEN' is not set or empty" - - - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} - if: ${{ !env.GH_USER }} - run: | - echo "::error::Secret 'GH_USER' is not set or empty" + verify_repo_secrets: + uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@refactor-release-workflow-structure + secrets: + gh_token: ${{ env.GH_TOKEN }} + gh_user: ${{ env.GH_USER }} + gh_mail: ${{ env.GH_EMAIL }} - - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} - if: ${{ !env.GH_EMAIL }} - run: | - echo "::error::Secret 'GH_EMAIL' is not set or empty" - - name: 🔎 Secrets verified - if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} - run: | - echo "::notice::All required secrets are present." + verify-repo-vars: + runs-on: ubuntu-latest + steps: - name: 🔎 Verify repo variables for ${{ github.repository }} run: | missing_vars=$(echo ${{ env.REQUIRED_VARS }} | tr ',' '\n' | while read var; do diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 89eba7e..db04f66 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -31,33 +31,18 @@ env: CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" jobs: - verify_repo_vars_and_secrets: - runs-on: ubuntu-latest - - # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) - # TODO move verification into github action - # TODO RnD more efficient way for secret checks without converting them to values - steps: - - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} - if: ${{ !env.GH_TOKEN }} - run: | - echo "::error::Secret 'GH_TOKEN' is not set or empty" - - - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} - if: ${{ !env.GH_USER }} - run: | - echo "::error::Secret 'GH_USER' is not set or empty" + verify-repo-secrets: + uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure + secrets: + gh_token: ${{ env.GH_TOKEN }} + gh_user: ${{ env.GH_USER }} + gh_mail: ${{ env.GH_EMAIL }} - - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} - if: ${{ !env.GH_EMAIL }} - run: | - echo "::error::Secret 'GH_EMAIL' is not set or empty" - - name: 🔎 Secrets verified - if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} - run: | - echo "::notice::All required secrets are present." + verify-repo-vars: + runs-on: ubuntu-latest + steps: - name: 🔎 Verify repo variables for ${{ github.repository }} run: | missing_vars=$(echo ${{ env.REQUIRED_VARS }} | tr ',' '\n' | while read var; do @@ -76,7 +61,8 @@ jobs: get-latest-release: runs-on: ubuntu-latest needs: - - verify_repo_vars_and_secrets + - verify-repo-secrets + - verify-repo-vars outputs: id: ${{ steps.latest-release.outputs.id }} name: ${{ steps.latest-release.outputs.name }} diff --git a/.github/workflows/verify_secrets.yml b/.github/workflows/verify_secrets.yml new file mode 100644 index 0000000..8e26dc4 --- /dev/null +++ b/.github/workflows/verify_secrets.yml @@ -0,0 +1,46 @@ +name: Verify repository secrets + +on: + workflow_call: + secrets: + gh_token: + required: true + gh_user: + required: true + gh_mail: + required: true + +env: + GH_TOKEN: ${{ secrets.gh_token || false }} + GH_USER: ${{ secrets.gh_user || false }} + GH_EMAIL: ${{ secrets.gh_mail || false }} + +jobs: + verify_secrets: + + runs-on: ubuntu-latest + + # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) + # TODO only check if no inputs provided + # TODO move verification into github action + + steps: + - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} + if: ${{ !env.GH_TOKEN }} + run: | + echo "::error::Secret 'GH_TOKEN' is not set or empty" + + - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} + if: ${{ !env.GH_USER }} + run: | + echo "::error::Secret 'GH_USER' is not set or empty" + + - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} + if: ${{ !env.GH_EMAIL }} + run: | + echo "::error::Secret 'GH_EMAIL' is not set or empty" + + - name: 🔎 Secrets verified + if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} + run: | + echo "::notice::All required secrets are present." \ No newline at end of file From e1a4c87900b4e8a2f6618b9d253ea302283c46f5 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 1 Nov 2024 08:39:34 +0100 Subject: [PATCH 03/58] Update secrets names --- .github/workflows/initial_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index bfb7295..c53c97e 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -38,9 +38,9 @@ jobs: verify_repo_secrets: uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@refactor-release-workflow-structure secrets: - gh_token: ${{ env.GH_TOKEN }} - gh_user: ${{ env.GH_USER }} - gh_mail: ${{ env.GH_EMAIL }} + token: ${{ env.GH_TOKEN }} + user: ${{ env.GH_USER }} + email: ${{ env.GH_EMAIL }} verify-repo-vars: From d82d357a17fbab0ffab8761c6497fde30729c8e5 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 1 Nov 2024 09:18:26 +0100 Subject: [PATCH 04/58] update caller workflow branch --- .github/workflows/reset_test_repo.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index a71d0be..d50c1cf 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -136,9 +136,9 @@ jobs: git push origin ${{ env.DEFAULT_BRANCH }} - name: Add initial-release workflow - # TODO change develop to main + # TODO change branch to main run: | - curl -O https://raw.githubusercontent.com/${{ github.repository }}/develop/caller_workflows/addon_repo_initial_release.yml + curl -O https://raw.githubusercontent.com/${{ github.repository }}/refactor-release-workflow-structure/caller_workflows/addon_repo_initial_release.yml mv addon_repo_initial_release.yml ./.github/workflows/initial_release.yml @@ -151,7 +151,7 @@ jobs: - name: Add release workflow run: | - curl -O https://raw.githubusercontent.com/${{ github.repository }}/develop/caller_workflows/addon_repo_release_trigger.yml + curl -O https://raw.githubusercontent.com/${{ github.repository }}/refactor-release-workflow-structure/caller_workflows/addon_repo_release_trigger.yml mv addon_repo_release_trigger.yml ./.github/workflows/release_trigger.yml From 9027898d39bd0396be7676ec745fba55a3ced0f9 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 1 Nov 2024 09:42:32 +0100 Subject: [PATCH 05/58] Update initial release caller workflow --- .github/workflows/initial_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index c53c97e..d1f5d3d 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -36,7 +36,7 @@ env: jobs: verify_repo_secrets: - uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@refactor-release-workflow-structure + uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure secrets: token: ${{ env.GH_TOKEN }} user: ${{ env.GH_USER }} From 71501af605e07bad1b410cc66e9cdb9dbe341da7 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 1 Nov 2024 09:56:18 +0100 Subject: [PATCH 06/58] Switch env to secrets --- .github/workflows/initial_release.yml | 6 +++--- .github/workflows/release_trigger.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index d1f5d3d..bbffcb2 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -38,9 +38,9 @@ jobs: verify_repo_secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure secrets: - token: ${{ env.GH_TOKEN }} - user: ${{ env.GH_USER }} - email: ${{ env.GH_EMAIL }} + token: ${{ secrets.token }} + user: ${{ secrets.user }} + email: ${{ secrets.email }} verify-repo-vars: diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index db04f66..83c88dd 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -34,9 +34,9 @@ jobs: verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure secrets: - gh_token: ${{ env.GH_TOKEN }} - gh_user: ${{ env.GH_USER }} - gh_mail: ${{ env.GH_EMAIL }} + token: ${{ secrets.token }} + user: ${{ secrets.user }} + email: ${{ secrets.email }} verify-repo-vars: From 91620a8bf2b65b6fd287089f4a0acf6edb69305e Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:16:08 +0100 Subject: [PATCH 07/58] Update verifier var names --- .github/workflows/initial_release.yml | 6 +++--- .github/workflows/verify_secrets.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index bbffcb2..bf46588 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -38,9 +38,9 @@ jobs: verify_repo_secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure secrets: - token: ${{ secrets.token }} - user: ${{ secrets.user }} - email: ${{ secrets.email }} + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} verify-repo-vars: diff --git a/.github/workflows/verify_secrets.yml b/.github/workflows/verify_secrets.yml index 8e26dc4..a6edb68 100644 --- a/.github/workflows/verify_secrets.yml +++ b/.github/workflows/verify_secrets.yml @@ -7,7 +7,7 @@ on: required: true gh_user: required: true - gh_mail: + gh_email: required: true env: From 966f5f6c1cf35c63f509d5eadc65f90a32d65728 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:20:03 +0100 Subject: [PATCH 08/58] Update verifier variables in release trigger --- .github/workflows/release_trigger.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 83c88dd..4c1b7d4 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -34,9 +34,9 @@ jobs: verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure secrets: - token: ${{ secrets.token }} - user: ${{ secrets.user }} - email: ${{ secrets.email }} + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} verify-repo-vars: From 3a400e382e9e23a237770af79f8b6fbf25519820 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:21:25 +0100 Subject: [PATCH 09/58] Update initial release trigger dependencies --- .github/workflows/initial_release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index bf46588..6a0a730 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -64,8 +64,9 @@ jobs: # TODO Move release query logic into github action get-latest-release: runs-on: ubuntu-latest - needs: - - verify_repo_vars_and_secrets + needs: + - verify_repo_secrets + - verify-repo-vars outputs: id: ${{ steps.latest-release.outputs.id }} name: ${{ steps.latest-release.outputs.name }} From f4fa5f12ea1378b1d6f9dcc7d307e5e38dc66760 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:32:03 +0100 Subject: [PATCH 10/58] Update secrets verifier --- .github/workflows/verify_secrets.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/verify_secrets.yml b/.github/workflows/verify_secrets.yml index a6edb68..ec50535 100644 --- a/.github/workflows/verify_secrets.yml +++ b/.github/workflows/verify_secrets.yml @@ -2,6 +2,11 @@ name: Verify repository secrets on: workflow_call: + inputs: + repo: + type: string + required: false + secrets: gh_token: required: true @@ -11,6 +16,7 @@ on: required: true env: + GH_REPO : ${{ inputs.repo || github.repository }} GH_TOKEN: ${{ secrets.gh_token || false }} GH_USER: ${{ secrets.gh_user || false }} GH_EMAIL: ${{ secrets.gh_mail || false }} @@ -22,20 +28,19 @@ jobs: # TODO include orgnaistion secrets - needs actions [secrets fine-grained permission](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28) # TODO only check if no inputs provided - # TODO move verification into github action steps: - - name: 🔎 Verify secret 'GH_TOKEN' for ${{ github.repository }} + - name: 🔎 Verify secret 'GH_TOKEN' for ${{ env.GH_REPO }} if: ${{ !env.GH_TOKEN }} run: | echo "::error::Secret 'GH_TOKEN' is not set or empty" - - name: 🔎 Verify secret 'GH_USER' for ${{ github.repository }} + - name: 🔎 Verify secret 'GH_USER' for ${{ env.GH_REPO }} if: ${{ !env.GH_USER }} run: | echo "::error::Secret 'GH_USER' is not set or empty" - - name: 🔎 Verify secret 'GH_EMAIL' for ${{ github.repository }} + - name: 🔎 Verify secret 'GH_EMAIL' for ${{ env.GH_REPO }} if: ${{ !env.GH_EMAIL }} run: | echo "::error::Secret 'GH_EMAIL' is not set or empty" @@ -43,4 +48,4 @@ jobs: - name: 🔎 Secrets verified if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} run: | - echo "::notice::All required secrets are present." \ No newline at end of file + echo "::notice::All required secrets are present." From 7c0caca8ee3091a4d5c64ff60de7d8e9fd0c5ca1 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:46:26 +0100 Subject: [PATCH 11/58] Move variable verifier to own workflow --- .github/workflows/initial_release.yml | 26 ++++++-------------- .github/workflows/release_trigger.yml | 23 ++++++----------- .github/workflows/verify_variables.yml | 34 ++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/verify_variables.yml diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 6a0a730..d3515aa 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -32,11 +32,12 @@ env: DRAFT: ${{ inputs.draft }} ARTIFACT_NAME: "${{ vars.PROJECT_NAME }}-package" PROJECT_NAME: "${{ vars.PROJECT_NAME }}" - REQUIRED_VARS: MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME jobs: verify_repo_secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} secrets: gh_token: ${{ secrets.token }} gh_user: ${{ secrets.user }} @@ -44,29 +45,16 @@ jobs: verify-repo-vars: - runs-on: ubuntu-latest - - steps: - - name: 🔎 Verify repo variables for ${{ github.repository }} - run: | - missing_vars=$(echo ${{ env.REQUIRED_VARS }} | tr ',' '\n' | while read var; do - gh variable list --repo ${{ github.repository }} --json name --jq '.[].name' | grep -qx "$var" || echo "$var" - done) - - if [ -n "$missing_vars" ]; then - echo "::error::The following required variables are missing: $missing_vars for repository ${{ github.repository }}" - exit 1 - else - echo "::notice::All required variables are present." - fi + uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@refactor-release-workflow-structure + with: + variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" + repo: ${{ github.repository }} # TODO Move release query logic into github action get-latest-release: runs-on: ubuntu-latest - needs: - - verify_repo_secrets - - verify-repo-vars + outputs: id: ${{ steps.latest-release.outputs.id }} name: ${{ steps.latest-release.outputs.name }} diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 4c1b7d4..4125009 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -31,8 +31,10 @@ env: CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" jobs: - verify-repo-secrets: + verify_repo_secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} secrets: gh_token: ${{ secrets.token }} gh_user: ${{ secrets.user }} @@ -40,21 +42,10 @@ jobs: verify-repo-vars: - runs-on: ubuntu-latest - - steps: - - name: 🔎 Verify repo variables for ${{ github.repository }} - run: | - missing_vars=$(echo ${{ env.REQUIRED_VARS }} | tr ',' '\n' | while read var; do - gh variable list --repo ${{ github.repository }} --json name --jq '.[].name' | grep -qx "$var" || echo "$var" - done) - - if [ -n "$missing_vars" ]; then - echo "::error::The following required variables are missing: $missing_vars for repository ${{ github.repository }}" - exit 1 - else - echo "::notice::All required variables are present." - fi + uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@refactor-release-workflow-structure + with: + variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" + repo: ${{ github.repository }} # TODO Move release query logic into github action diff --git a/.github/workflows/verify_variables.yml b/.github/workflows/verify_variables.yml new file mode 100644 index 0000000..d8fabc4 --- /dev/null +++ b/.github/workflows/verify_variables.yml @@ -0,0 +1,34 @@ +name: Verify repository variables + +on: + workflow_call: + inputs: + variables: + description: Repository variables as comma separated string without spaces + type: string + required: true + repo: + type: string + required: false + +env: + REPO_VARS: ${{ secrets.gh_token || false }} + GH_REPO : ${{ inputs.repo || github.repository }} + +jobs: + verify_variables: + runs-on: ubuntu-latest + + steps: + - name: 🔎 Verify repo variables for ${{ env.GH_REPO }} + run: | + missing_vars=$(echo ${{ env.REPO_VARS }} | tr ',' '\n' | while read var; do + gh variable list --repo ${{ env.GH_REPO }} --json name --jq '.[].name' | grep -qx "$var" || echo "$var" + done) + + if [ -n "$missing_vars" ]; then + echo "::error::The following required variables are missing: $missing_vars for repository ${{ env.GH_REPO }}" + exit 1 + else + echo "::notice::All required variables are present." + fi From e789c64d582ec9dba4a490c0659576dcbf43cdf2 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:48:32 +0100 Subject: [PATCH 12/58] Cleanup some dependencies --- .github/workflows/initial_release.yml | 4 +++- .github/workflows/release_trigger.yml | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index d3515aa..0cc514b 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -34,7 +34,7 @@ env: PROJECT_NAME: "${{ vars.PROJECT_NAME }}" jobs: - verify_repo_secrets: + verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} @@ -106,6 +106,8 @@ jobs: merge-to-main: runs-on: ubuntu-latest needs: + - verify-repo-secrets + - verify-repo-vars - get-latest-release steps: diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 4125009..d107c07 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -31,7 +31,7 @@ env: CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" jobs: - verify_repo_secrets: + verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} @@ -51,9 +51,7 @@ jobs: # TODO Move release query logic into github action get-latest-release: runs-on: ubuntu-latest - needs: - - verify-repo-secrets - - verify-repo-vars + outputs: id: ${{ steps.latest-release.outputs.id }} name: ${{ steps.latest-release.outputs.name }} @@ -111,7 +109,11 @@ jobs: increment-version: runs-on: ubuntu-latest - needs: get-latest-release + needs: + - verify-repo-secrets + - verify-repo-vars + - get-latest-release + env: release_date: ${{ needs.get-latest-release.outputs.date_published }} outputs: From cac0882936aa50f84279728b426c03d1035a26b5 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:56:14 +0100 Subject: [PATCH 13/58] Add token token to variable verifier --- .github/workflows/initial_release.yml | 2 ++ .github/workflows/release_trigger.yml | 2 ++ .github/workflows/verify_secrets.yml | 8 ++++---- .github/workflows/verify_variables.yml | 7 ++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 0cc514b..bf20e9b 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -49,6 +49,8 @@ jobs: with: variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} # TODO Move release query logic into github action diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index d107c07..57770a1 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -46,6 +46,8 @@ jobs: with: variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} # TODO Move release query logic into github action diff --git a/.github/workflows/verify_secrets.yml b/.github/workflows/verify_secrets.yml index ec50535..a2d5752 100644 --- a/.github/workflows/verify_secrets.yml +++ b/.github/workflows/verify_secrets.yml @@ -30,22 +30,22 @@ jobs: # TODO only check if no inputs provided steps: - - name: 🔎 Verify secret 'GH_TOKEN' for ${{ env.GH_REPO }} + - name: Verify secret 'GH_TOKEN' for ${{ env.GH_REPO }} if: ${{ !env.GH_TOKEN }} run: | echo "::error::Secret 'GH_TOKEN' is not set or empty" - - name: 🔎 Verify secret 'GH_USER' for ${{ env.GH_REPO }} + - name: Verify secret 'GH_USER' for ${{ env.GH_REPO }} if: ${{ !env.GH_USER }} run: | echo "::error::Secret 'GH_USER' is not set or empty" - - name: 🔎 Verify secret 'GH_EMAIL' for ${{ env.GH_REPO }} + - name: Verify secret 'GH_EMAIL' for ${{ env.GH_REPO }} if: ${{ !env.GH_EMAIL }} run: | echo "::error::Secret 'GH_EMAIL' is not set or empty" - - name: 🔎 Secrets verified + - name: Secrets verified if: ${{ env.GH_TOKEN && env.GH_USER && env.GH_EMAIL }} run: | echo "::notice::All required secrets are present." diff --git a/.github/workflows/verify_variables.yml b/.github/workflows/verify_variables.yml index d8fabc4..e33dadc 100644 --- a/.github/workflows/verify_variables.yml +++ b/.github/workflows/verify_variables.yml @@ -10,17 +10,22 @@ on: repo: type: string required: false + + secrets: + gh_token: + required: true env: REPO_VARS: ${{ secrets.gh_token || false }} GH_REPO : ${{ inputs.repo || github.repository }} + GH_TOKEN: ${{ secrets.gh_token }} jobs: verify_variables: runs-on: ubuntu-latest steps: - - name: 🔎 Verify repo variables for ${{ env.GH_REPO }} + - name: Verify repo variables for ${{ env.GH_REPO }} run: | missing_vars=$(echo ${{ env.REPO_VARS }} | tr ',' '\n' | while read var; do gh variable list --repo ${{ env.GH_REPO }} --json name --jq '.[].name' | grep -qx "$var" || echo "$var" From 6b8c0afeff537655c33a7b87429350d1f62bd632 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 10:59:14 +0100 Subject: [PATCH 14/58] Update variable ref --- .github/workflows/verify_variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_variables.yml b/.github/workflows/verify_variables.yml index e33dadc..51ca46d 100644 --- a/.github/workflows/verify_variables.yml +++ b/.github/workflows/verify_variables.yml @@ -16,7 +16,7 @@ on: required: true env: - REPO_VARS: ${{ secrets.gh_token || false }} + REPO_VARS: ${{ inputs.variables || false }} GH_REPO : ${{ inputs.repo || github.repository }} GH_TOKEN: ${{ secrets.gh_token }} From 4f8397574ec4a59526916adad25ad282b7085e7d Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 11:47:56 +0100 Subject: [PATCH 15/58] Move release query to own workflow --- .github/workflows/initial_release.yml | 58 ++++----------- .github/workflows/query_latest_release.yml | 85 ++++++++++++++++++++++ 2 files changed, 98 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/query_latest_release.yml diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index bf20e9b..5772907 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -34,6 +34,14 @@ env: PROJECT_NAME: "${{ vars.PROJECT_NAME }}" jobs: + get-latest-release: + uses: ynput/ops-repo-automation/.github/workflows/query_latest_release.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} + + verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure with: @@ -52,54 +60,14 @@ jobs: secrets: gh_token: ${{ secrets.token }} - - # TODO Move release query logic into github action - get-latest-release: + verify-latest-release: runs-on: ubuntu-latest - - outputs: - id: ${{ steps.latest-release.outputs.id }} - name: ${{ steps.latest-release.outputs.name }} - tag: ${{ steps.latest-release.outputs.tag }} - date_created: ${{ steps.latest-release.outputs.date_created }} - date_published: ${{ steps.latest-release.outputs.date_published }} - draft: ${{ steps.latest-release.outputs.draft }} - pre_release: ${{ steps.latest-release.outputs.pre_release}} + needs: + - get-latest-release steps: - - name: Get latest release - id: latest-release - run: | - declare -A release_option_map=( - ["id"]="id" - ["createdAt"]="date_created" - ["publishedAt"]="date_published" - ["tagName"]="tag" - ["name"]="name" - ["isDraft"]="draft" - ["isPrerelease"]="pre_release" - ) - - key_list=$(IFS=,; echo "${!release_option_map[*]}") - release=$(gh release view --repo ${{ github.repository }} --json $key_list || true) - - for key in "${!release_option_map[@]}"; do - value=$(echo "$release" | jq -r ".$key") - echo "${release_option_map[$key]}=$value" >> $GITHUB_OUTPUT - done - - - name: Show release data - run: | - echo "Release ID: ${{ steps.latest-release.outputs.id }}" - echo "Release Name: ${{ steps.latest-release.outputs.name }}" - echo "Tag Name: ${{ steps.latest-release.outputs.tag }}" - echo "Date Created: ${{ steps.latest-release.outputs.date_created }}" - echo "Date Published: ${{ steps.latest-release.outputs.date_published }}" - echo "Draft Status: ${{ steps.latest-release.outputs.draft }}" - echo "Pre-release Status: ${{ steps.latest-release.outputs.pre_release }}" - - name: Test existing release - if: ${{ steps.latest-release.outputs.date_published }} + if: ${{ needs.get-latest-release.outputs.date_published }} run: | echo "::error::An existing releases was found for ${{ github.repository }}. Please use the general release-trigger for further releases." exit 1 @@ -110,7 +78,7 @@ jobs: needs: - verify-repo-secrets - verify-repo-vars - - get-latest-release + - verify-latest-release steps: - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} diff --git a/.github/workflows/query_latest_release.yml b/.github/workflows/query_latest_release.yml new file mode 100644 index 0000000..05105c6 --- /dev/null +++ b/.github/workflows/query_latest_release.yml @@ -0,0 +1,85 @@ +name: Query latest release + +on: + workflow_call: + inputs: + repo: + type: string + required: false + + secrets: + gh_token: + required: true + + outputs: + id: + description: Release ID + value: ${{ jobs.latest-release.outputs.id }} + name: + description: Release name + value: ${{ jobs.latest-release.outputs.name }} + tag: + description: Release ID + value: ${{ jobs.latest-release.outputs.tag }} + date_created: + description: Release name + value: ${{ jobs.latest-release.outputs.date_created }} + date_published: + description: Release ID + value: ${{ jobs.latest-release.outputs.date_published }} + draft: + description: Release name + value: ${{ jobs.latest-release.outputs.draft }} + pre_release: + description: Release name + value: ${{ jobs.latest-release.outputs.pre_release }} + +env: + GH_REPO : ${{ inputs.repo || github.repository }} + GH_TOKEN: ${{ secrets.gh_token || false }} + +jobs: + latest-release: + + runs-on: ubuntu-latest + + outputs: + id: ${{ steps.latest-release.outputs.id }} + name: ${{ steps.latest-release.outputs.name }} + tag: ${{ steps.latest-release.outputs.tag }} + date_created: ${{ steps.latest-release.outputs.date_created }} + date_published: ${{ steps.latest-release.outputs.date_published }} + draft: ${{ steps.latest-release.outputs.draft }} + pre_release: ${{ steps.latest-release.outputs.pre_release}} + + steps: + - name: Get latest release + id: latest-release + run: | + declare -A release_option_map=( + ["id"]="id" + ["createdAt"]="date_created" + ["publishedAt"]="date_published" + ["tagName"]="tag" + ["name"]="name" + ["isDraft"]="draft" + ["isPrerelease"]="pre_release" + ) + + key_list=$(IFS=,; echo "${!release_option_map[*]}") + release=$(gh release view --repo ${{ env.GH_REPO }} --json $key_list || true) + + for key in "${!release_option_map[@]}"; do + value=$(echo "$release" | jq -r ".$key") + echo "${release_option_map[$key]}=$value" >> $GITHUB_OUTPUT + done + + - name: Show release data + run: | + echo "Release ID: ${{ steps.latest-release.outputs.id }}" + echo "Release Name: ${{ steps.latest-release.outputs.name }}" + echo "Tag Name: ${{ steps.latest-release.outputs.tag }}" + echo "Date Created: ${{ steps.latest-release.outputs.date_created }}" + echo "Date Published: ${{ steps.latest-release.outputs.date_published }}" + echo "Draft Status: ${{ steps.latest-release.outputs.draft }}" + echo "Pre-release Status: ${{ steps.latest-release.outputs.pre_release }}" From 2b9fd0cf66d384e67fc716ea8b4143076c2967dc Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 11:55:38 +0100 Subject: [PATCH 16/58] Update job name --- .github/workflows/query_latest_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/query_latest_release.yml b/.github/workflows/query_latest_release.yml index 05105c6..332e745 100644 --- a/.github/workflows/query_latest_release.yml +++ b/.github/workflows/query_latest_release.yml @@ -39,7 +39,7 @@ env: GH_TOKEN: ${{ secrets.gh_token || false }} jobs: - latest-release: + query-latest-release: runs-on: ubuntu-latest From d5d448b10732fd2c6a183bcb9a06d41cf439cf74 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 11:57:09 +0100 Subject: [PATCH 17/58] Update verify order --- .github/workflows/initial_release.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 5772907..09de91f 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -42,6 +42,19 @@ jobs: gh_token: ${{ secrets.token }} + verify-latest-release: + runs-on: ubuntu-latest + needs: + - get-latest-release + + steps: + - name: Test existing release + if: ${{ needs.get-latest-release.outputs.date_published }} + run: | + echo "::error::An existing releases was found for ${{ github.repository }}. Please use the general release-trigger for further releases." + exit 1 + + verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure with: @@ -60,25 +73,13 @@ jobs: secrets: gh_token: ${{ secrets.token }} - verify-latest-release: - runs-on: ubuntu-latest - needs: - - get-latest-release - - steps: - - name: Test existing release - if: ${{ needs.get-latest-release.outputs.date_published }} - run: | - echo "::error::An existing releases was found for ${{ github.repository }}. Please use the general release-trigger for further releases." - exit 1 - merge-to-main: runs-on: ubuntu-latest needs: + - verify-latest-release - verify-repo-secrets - verify-repo-vars - - verify-latest-release steps: - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} From dfdae135076b039bc0a02b5c531c52f1e27e9e7e Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 11:59:12 +0100 Subject: [PATCH 18/58] Update initial release trigger inputs --- .github/workflows/initial_release.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 09de91f..abe4de8 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -5,13 +5,7 @@ on: inputs: draft: type: boolean - major: - type: string - minor: - type: string - patch: - type: string - name: + release_overwrite: type: string secrets: From 244d038567620cd9518e897902e0d9acd7ac0144 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 2 Nov 2024 12:03:59 +0100 Subject: [PATCH 19/58] Update release trigger structure --- .github/workflows/release_trigger.yml | 89 +++++++++------------------ 1 file changed, 29 insertions(+), 60 deletions(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 57770a1..83e9323 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -31,90 +31,59 @@ env: CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" jobs: - verify-repo-secrets: - uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure - with: - repo: ${{ github.repository }} - secrets: - gh_token: ${{ secrets.token }} - gh_user: ${{ secrets.user }} - gh_email: ${{ secrets.email }} - - - verify-repo-vars: - uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@refactor-release-workflow-structure + get-latest-release: + uses: ynput/ops-repo-automation/.github/workflows/query_latest_release.yml@refactor-release-workflow-structure with: - variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" repo: ${{ github.repository }} secrets: gh_token: ${{ secrets.token }} - # TODO Move release query logic into github action - get-latest-release: + verify-latest-release: runs-on: ubuntu-latest - - outputs: - id: ${{ steps.latest-release.outputs.id }} - name: ${{ steps.latest-release.outputs.name }} - tag: ${{ steps.latest-release.outputs.tag }} - date_created: ${{ steps.latest-release.outputs.date_created }} - date_published: ${{ steps.latest-release.outputs.date_published }} - draft: ${{ steps.latest-release.outputs.draft }} - pre_release: ${{ steps.latest-release.outputs.pre_release}} + needs: + - get-latest-release steps: - - name: Get latest release - id: latest-release - run: | - declare -A release_option_map=( - ["id"]="id" - ["createdAt"]="date_created" - ["publishedAt"]="date_published" - ["tagName"]="tag" - ["name"]="name" - ["isDraft"]="draft" - ["isPrerelease"]="pre_release" - ) - - key_list=$(IFS=,; echo "${!release_option_map[*]}") - release=$(gh release view --repo ${{ github.repository }} --json $key_list || true) - - for key in "${!release_option_map[@]}"; do - value=$(echo "$release" | jq -r ".$key") - echo "${release_option_map[$key]}=$value" >> $GITHUB_OUTPUT - done - - - name: Show release data - # TODO create a loop for this - run: | - echo "Release ID: ${{ steps.latest-release.outputs.id }}" - echo "Release Name: ${{ steps.latest-release.outputs.name }}" - echo "Tag Name: ${{ steps.latest-release.outputs.tag }}" - echo "Date Created: ${{ steps.latest-release.outputs.date_created }}" - echo "Date Published: ${{ steps.latest-release.outputs.date_published }}" - echo "Draft Status: ${{ steps.latest-release.outputs.draft }}" - echo "Pre-release Status: ${{ steps.latest-release.outputs.pre_release }}" - - name: Test existing release - if: ${{ ! steps.latest-release.outputs.date_published }} + if: ${{ ! needs.get-latest-release.outputs.date_published }} run: | echo "::warning::No releases found for ${{ github.repository }}. Please use the Initial Release Trigger workflow. exit 1 - name: Test release drafts - if: ${{ fromJson(steps.latest-release.outputs.draft) }} + if: ${{ fromJson(needs.get-latest-release.outputs.draft) }} run: | - echo "::warning::Release draft already present: ${{ steps.latest-release.outputs.name }}" + echo "::warning::Release draft already present: ${{ needs.get-latest-release.outputs.name }}" exit 0 + + verify-repo-secrets: + uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} + + + verify-repo-vars: + uses: ynput/ops-repo-automation/.github/workflows/verify_variables.yml@refactor-release-workflow-structure + with: + variables: "MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME" + repo: ${{ github.repository }} + secrets: + gh_token: ${{ secrets.token }} + increment-version: runs-on: ubuntu-latest needs: + - get-latest-release + - verify-latest-release - verify-repo-secrets - verify-repo-vars - - get-latest-release env: release_date: ${{ needs.get-latest-release.outputs.date_published }} From c672537719e43c81478696f9f5093f2f82b3028c Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Wed, 13 Nov 2024 08:30:28 +0100 Subject: [PATCH 20/58] Add TODO --- .github/workflows/release_trigger.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 83e9323..7251bcb 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -77,18 +77,17 @@ jobs: gh_token: ${{ secrets.token }} - increment-version: + get-pr-information: runs-on: ubuntu-latest needs: - - get-latest-release - verify-latest-release - - verify-repo-secrets - - verify-repo-vars env: release_date: ${{ needs.get-latest-release.outputs.date_published }} + outputs: - next-version: "${{ steps.set-tag.outputs.NEXT_TAG }}" + label-list: "${{ steps.pr-query.outputs.label-list }}" + bump-increment: "${{ steps.pr-query.outputs.bump-increment }}" changelog: "${{ steps.pr-query.outputs.changelog-markdown }}" steps: @@ -107,6 +106,21 @@ jobs: echo "bump-increment: ${{ steps.pr-query.outputs.bump-increment }}" echo "changelog: ${{ steps.pr-query.outputs.changelog-markdown }}" + validate-pr-information: + + + increment-version: + runs-on: ubuntu-latest + needs: + - get-pr-information + - verify-latest-release + - verify-repo-secrets + - verify-repo-vars + + outputs: + next-version: "${{ steps.set-tag.outputs.NEXT_TAG }}" + + steps: - name: Check for existing PRs if: ${{ !fromJson(steps.pr-query.outputs.raw-output) }} run: | @@ -115,7 +129,7 @@ jobs: exit 1 - name: Check for existing PR labels - if: ${{ !fromJson(steps.pr-query.outputs.label-list) }} + if: ${{ !steps.pr-query.outputs.label-list }} # TODO enhance output to show wich PR run: | echo "::error:: No PR labels found. Can't create a new release." From 2c974b5e5be29a0d56125964a213e586cc4b9112 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Thu, 14 Nov 2024 09:29:02 +0100 Subject: [PATCH 21/58] Fix job dependency issues --- .github/workflows/query_latest_release.yml | 26 ++++++--- .github/workflows/release_trigger.yml | 66 ++++++++-------------- 2 files changed, 42 insertions(+), 50 deletions(-) diff --git a/.github/workflows/query_latest_release.yml b/.github/workflows/query_latest_release.yml index 332e745..cee7495 100644 --- a/.github/workflows/query_latest_release.yml +++ b/.github/workflows/query_latest_release.yml @@ -14,25 +14,25 @@ on: outputs: id: description: Release ID - value: ${{ jobs.latest-release.outputs.id }} + value: ${{ jobs.query-latest-release.outputs.id }} name: description: Release name - value: ${{ jobs.latest-release.outputs.name }} + value: ${{ jobs.query-latest-release.outputs.name }} tag: description: Release ID - value: ${{ jobs.latest-release.outputs.tag }} + value: ${{ jobs.query-latest-release.outputs.tag }} date_created: description: Release name - value: ${{ jobs.latest-release.outputs.date_created }} + value: ${{ jobs.query-latest-release.outputs.date_created }} date_published: description: Release ID - value: ${{ jobs.latest-release.outputs.date_published }} + value: ${{ jobs.query-latest-release.outputs.date_published }} draft: description: Release name - value: ${{ jobs.latest-release.outputs.draft }} + value: ${{ jobs.query-latest-release.outputs.draft }} pre_release: description: Release name - value: ${{ jobs.latest-release.outputs.pre_release }} + value: ${{ jobs.query-latest-release.outputs.pre_release }} env: GH_REPO : ${{ inputs.repo || github.repository }} @@ -83,3 +83,15 @@ jobs: echo "Date Published: ${{ steps.latest-release.outputs.date_published }}" echo "Draft Status: ${{ steps.latest-release.outputs.draft }}" echo "Pre-release Status: ${{ steps.latest-release.outputs.pre_release }}" + + - name: Test existing release + if: ${{ ! steps.latest-release.outputs.date_published }} + run: | + echo "::warning::No releases found for ${{ github.repository }}. Please use the Initial Release Trigger workflow. + exit 1 + + - name: Test release drafts + if: ${{ fromJson(steps.latest-release.outputs.draft) }} + run: | + echo "::warning::Release draft already present: ${{ steps.latest-release.outputs.name }}" + exit 0 diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 7251bcb..92ea803 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -31,7 +31,7 @@ env: CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" jobs: - get-latest-release: + verify-latest-release: uses: ynput/ops-repo-automation/.github/workflows/query_latest_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} @@ -39,25 +39,6 @@ jobs: gh_token: ${{ secrets.token }} - verify-latest-release: - runs-on: ubuntu-latest - needs: - - get-latest-release - - steps: - - name: Test existing release - if: ${{ ! needs.get-latest-release.outputs.date_published }} - run: | - echo "::warning::No releases found for ${{ github.repository }}. Please use the Initial Release Trigger workflow. - exit 1 - - - name: Test release drafts - if: ${{ fromJson(needs.get-latest-release.outputs.draft) }} - run: | - echo "::warning::Release draft already present: ${{ needs.get-latest-release.outputs.name }}" - exit 0 - - verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure with: @@ -77,13 +58,13 @@ jobs: gh_token: ${{ secrets.token }} - get-pr-information: + validate-pr-information: runs-on: ubuntu-latest needs: - verify-latest-release env: - release_date: ${{ needs.get-latest-release.outputs.date_published }} + release_date: ${{ needs.verify-latest-release.outputs.date_published }} outputs: label-list: "${{ steps.pr-query.outputs.label-list }}" @@ -106,35 +87,20 @@ jobs: echo "bump-increment: ${{ steps.pr-query.outputs.bump-increment }}" echo "changelog: ${{ steps.pr-query.outputs.changelog-markdown }}" - validate-pr-information: - - - increment-version: - runs-on: ubuntu-latest - needs: - - get-pr-information - - verify-latest-release - - verify-repo-secrets - - verify-repo-vars - - outputs: - next-version: "${{ steps.set-tag.outputs.NEXT_TAG }}" - - steps: - name: Check for existing PRs if: ${{ !fromJson(steps.pr-query.outputs.raw-output) }} run: | echo "pr_list: ${{ steps.pr-query.outputs.raw-output }}" echo "::error::No merged PRs found since last release." exit 1 - + - name: Check for existing PR labels if: ${{ !steps.pr-query.outputs.label-list }} # TODO enhance output to show wich PR run: | echo "::error:: No PR labels found. Can't create a new release." exit 1 - + - name: ❗ Validate labels if: ${{ !steps.pr-query.outputs.bump-increment }} run: | @@ -142,13 +108,23 @@ jobs: echo "::error:: No valid versioning labels found in PRs. Only found these labels: ${{ steps.pr-query.outputs.label-list }}. Are you sure you want to create a new release?" exit 1 + + increment-version: + runs-on: ubuntu-latest + needs: + - validate-pr-information + + outputs: + next-version: "${{ steps.set-tag.outputs.NEXT_TAG }}" + + steps: - name: 🔼 Get next Version Tag if: ${{ ! inputs.release_overwrite }} uses: reecetech/version-increment@2024.4.4 id: calculated_version_tag with: scheme: semver - increment: ${{ steps.pr-query.outputs.bump-increment }} + increment: ${{ needs.validate-pr-information.outputs.bump-increment }} release_branch: ${{ vars.MAIN_BRANCH }} use_api: true @@ -168,7 +144,11 @@ jobs: merge-to-main: runs-on: ubuntu-latest - needs: increment-version + needs: + - increment-version + - verify-repo-secrets + - verify-repo-vars + - verify-latest-release steps: - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} @@ -199,7 +179,6 @@ jobs: build-from-main: runs-on: ubuntu-latest needs: - - get-latest-release - increment-version - merge-to-main env: @@ -321,13 +300,14 @@ jobs: create-release: runs-on: ubuntu-latest needs: + - validate-pr-information - build-from-main - increment-version # TODO remove obsolete env var env: NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}" RELEASE_COMMIT: "${{ needs.build-from-main.outputs.latest_commit }}" - CHANGELOG: "${{ needs.increment-version.outputs.changelog }}" + CHANGELOG: "${{ needs.validate-pr-information.outputs.changelog }}" steps: - name: 🔽 Download zip artifacts From 1358312d5469ef9074dd6648f0c4f95f63100363 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Thu, 14 Nov 2024 10:01:31 +0100 Subject: [PATCH 22/58] Move validation of pr data to own workflow --- .github/workflows/release_trigger.yml | 51 ++--------------- .github/workflows/verify_pr_data.yml | 80 +++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/verify_pr_data.yml diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 92ea803..9cf6620 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -59,54 +59,13 @@ jobs: validate-pr-information: - runs-on: ubuntu-latest needs: - verify-latest-release - - env: - release_date: ${{ needs.verify-latest-release.outputs.date_published }} - - outputs: - label-list: "${{ steps.pr-query.outputs.label-list }}" - bump-increment: "${{ steps.pr-query.outputs.bump-increment }}" - changelog: "${{ steps.pr-query.outputs.changelog-markdown }}" - - steps: - - name: Query PR data - id: pr-query - uses: ynput/github-query@generate-changelog - with: - repo: "${{ github.repository }}" - date: "${{ env.release_date }}" - query_parameters: "body,labels,title,id,number,url" - changelog_labels: "${{ env.CHANGELOG_ORDER }}" - - - name: Show debug output - run: | - echo "label-list: ${{ steps.pr-query.outputs.label-list }}" - echo "bump-increment: ${{ steps.pr-query.outputs.bump-increment }}" - echo "changelog: ${{ steps.pr-query.outputs.changelog-markdown }}" - - - name: Check for existing PRs - if: ${{ !fromJson(steps.pr-query.outputs.raw-output) }} - run: | - echo "pr_list: ${{ steps.pr-query.outputs.raw-output }}" - echo "::error::No merged PRs found since last release." - exit 1 - - - name: Check for existing PR labels - if: ${{ !steps.pr-query.outputs.label-list }} - # TODO enhance output to show wich PR - run: | - echo "::error:: No PR labels found. Can't create a new release." - exit 1 - - - name: ❗ Validate labels - if: ${{ !steps.pr-query.outputs.bump-increment }} - run: | - # TODO Format using line breaks - not supported by annotations - echo "::error:: No valid versioning labels found in PRs. Only found these labels: ${{ steps.pr-query.outputs.label-list }}. Are you sure you want to create a new release?" - exit 1 + uses: ynput/ops-repo-automation/.github/workflows/verify_pr_data.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + latest-release: ${{ needs.verify-latest-release.outputs.date_published }} + changelog_order: ${{ vars.CHANGELOG_ORDER || false }} increment-version: diff --git a/.github/workflows/verify_pr_data.yml b/.github/workflows/verify_pr_data.yml new file mode 100644 index 0000000..1df22f3 --- /dev/null +++ b/.github/workflows/verify_pr_data.yml @@ -0,0 +1,80 @@ +name: Validate pr information + +on: + workflow_call: + inputs: + repo: + type: string + required: false + latest_release: + type: string + required: true + changelog_order: + type: string + required: true + + secrets: + gh_token: + required: true + + outputs: + label-list: + description: List of unique labels + value: ${{ jobs.validate-pr-information.outputs.label-list }} + bump-increment: + description: Calcualted bump increment based on pr labels + value: ${{ jobs.validate-pr-information.outputs.bump-increment }} + changelog: + description: Markdown formatted changelog + value: ${{ jobs.validate-pr-information.outputs.changelog }} + +env: + GH_REPO : ${{ inputs.repo || github.repository }} + GH_TOKEN: ${{ secrets.gh_token || false }} + RELEASE_DATE: ${{inputs.latest_release }} + +jobs: + validate-pr-information: + runs-on: ubuntu-latest + + outputs: + label-list: "${{ steps.pr-query.outputs.label-list }}" + bump-increment: "${{ steps.pr-query.outputs.bump-increment }}" + changelog: "${{ steps.pr-query.outputs.changelog-markdown }}" + + steps: + - name: Query PR data + id: pr-query + uses: ynput/github-query@main + with: + repo: "${{ env.GH_REPO }}" + date: "${{ env.RELEASE_DATE }}" + query_parameters: "body,labels,title,id,number,url" + changelog_labels: "${{ inputs.changelog_order }}" + + - name: Show debug output + run: | + echo "label-list: ${{ steps.pr-query.outputs.label-list }}" + echo "bump-increment: ${{ steps.pr-query.outputs.bump-increment }}" + echo "changelog: ${{ steps.pr-query.outputs.changelog-markdown }}" + + - name: Check for existing PRs + if: ${{ !fromJson(steps.pr-query.outputs.raw-output) }} + run: | + echo "pr_list: ${{ steps.pr-query.outputs.raw-output }}" + echo "::error::No merged PRs found since last release." + exit 1 + + - name: Check for existing PR labels + if: ${{ !steps.pr-query.outputs.label-list }} + # TODO enhance output to show wich PR + run: | + echo "::error:: No PR labels found. Can't create a new release." + exit 1 + + - name: ❗ Validate labels + if: ${{ !steps.pr-query.outputs.bump-increment }} + run: | + # TODO Format using line breaks - not supported by annotations + echo "::error:: No valid versioning labels found in PRs. Only found these labels: ${{ steps.pr-query.outputs.label-list }}. Are you sure you want to create a new release?" + exit 1 From 3235ffb5107ef4bf7cf212fa519da605f1b26094 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 15 Nov 2024 09:35:13 +0100 Subject: [PATCH 23/58] Update release verification Update workflow names --- .github/workflows/initial_release.yml | 18 +++--------------- .github/workflows/release_trigger.yml | 5 +++-- ...t_release.yml => verify_latest_release.yml} | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 20 deletions(-) rename .github/workflows/{query_latest_release.yml => verify_latest_release.yml} (83%) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index abe4de8..aed243e 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -28,27 +28,15 @@ env: PROJECT_NAME: "${{ vars.PROJECT_NAME }}" jobs: - get-latest-release: - uses: ynput/ops-repo-automation/.github/workflows/query_latest_release.yml@refactor-release-workflow-structure + verify-latest-release: + uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} + expect_release: false secrets: gh_token: ${{ secrets.token }} - verify-latest-release: - runs-on: ubuntu-latest - needs: - - get-latest-release - - steps: - - name: Test existing release - if: ${{ needs.get-latest-release.outputs.date_published }} - run: | - echo "::error::An existing releases was found for ${{ github.repository }}. Please use the general release-trigger for further releases." - exit 1 - - verify-repo-secrets: uses: ynput/ops-repo-automation/.github/workflows/verify_secrets.yml@refactor-release-workflow-structure with: diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 9cf6620..f0389a5 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -32,9 +32,10 @@ env: jobs: verify-latest-release: - uses: ynput/ops-repo-automation/.github/workflows/query_latest_release.yml@refactor-release-workflow-structure + uses: ynput/ops-repo-automation/.github/workflows/verify_latest_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} + expect_release: true secrets: gh_token: ${{ secrets.token }} @@ -64,7 +65,7 @@ jobs: uses: ynput/ops-repo-automation/.github/workflows/verify_pr_data.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} - latest-release: ${{ needs.verify-latest-release.outputs.date_published }} + latest_release: ${{ needs.verify-latest-release.outputs.date_published }} changelog_order: ${{ vars.CHANGELOG_ORDER || false }} diff --git a/.github/workflows/query_latest_release.yml b/.github/workflows/verify_latest_release.yml similarity index 83% rename from .github/workflows/query_latest_release.yml rename to .github/workflows/verify_latest_release.yml index cee7495..74932a1 100644 --- a/.github/workflows/query_latest_release.yml +++ b/.github/workflows/verify_latest_release.yml @@ -6,6 +6,9 @@ on: repo: type: string required: false + expect_release: + type: boolean + required: false secrets: gh_token: @@ -84,14 +87,20 @@ jobs: echo "Draft Status: ${{ steps.latest-release.outputs.draft }}" echo "Pre-release Status: ${{ steps.latest-release.outputs.pre_release }}" + - name: Test non-existing release + if: steps.latest-release.outputs.date_published && !inputs.expect_release + run: | + echo "::error::Release already exists, but wasn't expected for ${{ inputs.repo }}. - Please use the release-trigger workflow instead" + exit 1 + - name: Test existing release - if: ${{ ! steps.latest-release.outputs.date_published }} + if: !steps.latest-release.outputs.date_published && inputs.expect_release run: | - echo "::warning::No releases found for ${{ github.repository }}. Please use the Initial Release Trigger workflow. + echo "::error::No release found, but was expected for ${{ inputs.repo }}. - Please use the initial-release workflow instead" exit 1 - name: Test release drafts - if: ${{ fromJson(steps.latest-release.outputs.draft) }} + if: fromJson(steps.latest-release.outputs.draft) run: | echo "::warning::Release draft already present: ${{ steps.latest-release.outputs.name }}" exit 0 From 374bec0c6574cb32edc929559493bf7025e9222f Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 15 Nov 2024 09:46:50 +0100 Subject: [PATCH 24/58] Fix syntax --- .github/workflows/verify_latest_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/verify_latest_release.yml b/.github/workflows/verify_latest_release.yml index 74932a1..8ff5362 100644 --- a/.github/workflows/verify_latest_release.yml +++ b/.github/workflows/verify_latest_release.yml @@ -88,19 +88,19 @@ jobs: echo "Pre-release Status: ${{ steps.latest-release.outputs.pre_release }}" - name: Test non-existing release - if: steps.latest-release.outputs.date_published && !inputs.expect_release + if: ${{ steps.latest-release.outputs.date_published && !inputs.expect_release }} run: | echo "::error::Release already exists, but wasn't expected for ${{ inputs.repo }}. - Please use the release-trigger workflow instead" exit 1 - name: Test existing release - if: !steps.latest-release.outputs.date_published && inputs.expect_release + if: ${{ !steps.latest-release.outputs.date_published && inputs.expect_release }} run: | echo "::error::No release found, but was expected for ${{ inputs.repo }}. - Please use the initial-release workflow instead" exit 1 - name: Test release drafts - if: fromJson(steps.latest-release.outputs.draft) + if: ${{ fromJson(steps.latest-release.outputs.draft) }} run: | echo "::warning::Release draft already present: ${{ steps.latest-release.outputs.name }}" exit 0 From 7b2973af23149db02fb0cb97034b564a2d7c54a0 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Fri, 15 Nov 2024 09:52:15 +0100 Subject: [PATCH 25/58] Update naming --- .github/workflows/verify_latest_release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/verify_latest_release.yml b/.github/workflows/verify_latest_release.yml index 8ff5362..b99a94d 100644 --- a/.github/workflows/verify_latest_release.yml +++ b/.github/workflows/verify_latest_release.yml @@ -1,4 +1,4 @@ -name: Query latest release +name: verify latest release on: workflow_call: @@ -17,32 +17,32 @@ on: outputs: id: description: Release ID - value: ${{ jobs.query-latest-release.outputs.id }} + value: ${{ jobs.verify-release.outputs.id }} name: description: Release name - value: ${{ jobs.query-latest-release.outputs.name }} + value: ${{ jobs.verify-release.outputs.name }} tag: description: Release ID - value: ${{ jobs.query-latest-release.outputs.tag }} + value: ${{ jobs.verify-release.outputs.tag }} date_created: description: Release name - value: ${{ jobs.query-latest-release.outputs.date_created }} + value: ${{ jobs.verify-release.outputs.date_created }} date_published: description: Release ID - value: ${{ jobs.query-latest-release.outputs.date_published }} + value: ${{ jobs.verify-release.outputs.date_published }} draft: description: Release name - value: ${{ jobs.query-latest-release.outputs.draft }} + value: ${{ jobs.verify-release.outputs.draft }} pre_release: description: Release name - value: ${{ jobs.query-latest-release.outputs.pre_release }} + value: ${{ jobs.verify-release.outputs.pre_release }} env: GH_REPO : ${{ inputs.repo || github.repository }} GH_TOKEN: ${{ secrets.gh_token || false }} jobs: - query-latest-release: + verify-release: runs-on: ubuntu-latest From 1f89e68fc8e7e3cfbf29e39ba6486cddd2ebea4d Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 17 Nov 2024 11:15:47 +0100 Subject: [PATCH 26/58] FIx if check issue --- .github/workflows/verify_latest_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_latest_release.yml b/.github/workflows/verify_latest_release.yml index b99a94d..67de47d 100644 --- a/.github/workflows/verify_latest_release.yml +++ b/.github/workflows/verify_latest_release.yml @@ -100,7 +100,7 @@ jobs: exit 1 - name: Test release drafts - if: ${{ fromJson(steps.latest-release.outputs.draft) }} + if: ${{ inputs.expect_release && fromJson(steps.latest-release.outputs.draft) }} run: | echo "::warning::Release draft already present: ${{ steps.latest-release.outputs.name }}" exit 0 From f6bef5c7b9116984f0a95fa2142b476850d975de Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 17 Nov 2024 11:46:24 +0100 Subject: [PATCH 27/58] Refactor branch merge into own reusable workflow --- .github/workflows/initial_release.yml | 35 ++++--------- .github/workflows/merge_branch.yml | 54 +++++++++++++++++++++ .github/workflows/release_trigger.yml | 3 +- .github/workflows/verify_latest_release.yml | 2 +- 4 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/merge_branch.yml diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index aed243e..4d75d30 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -57,37 +57,20 @@ jobs: merge-to-main: - runs-on: ubuntu-latest needs: - verify-latest-release - verify-repo-secrets - verify-repo-vars - steps: - - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} - uses: actions/checkout@v4 - with: - ref: ${{ vars.MAIN_BRANCH }} - fetch-depth: 0 - - - name: 🔑 Set Bot Authentication - run: | - git config --global user.name "${{ env.GH_USER }}" - git config --global user.email "${{ env.GH_EMAIL }}" - - - name: 🔀 Merge ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }} - run: | - git pull origin ${{ github.ref_name }} - git merge --no-ff origin/${{ github.ref_name }} -m "[Automated] Merged ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }}" - - # TODO implement this using gh command - - name: 🔏 Push to protected main branch - uses: CasperWA/push-protected@v2.15.0 - with: - token: ${{ env.GH_TOKEN }} - branch: ${{ vars.MAIN_BRANCH }} - tags: false - unprotect_reviews: false + uses: ynput/ops-repo-automation/.github/workflows/merge_branch.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + checkout_branch: ${{ vars.MAIN_BRANCH }} + merge_from_branch: ${{ github.ref_name }} + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} build-from-main: diff --git a/.github/workflows/merge_branch.yml b/.github/workflows/merge_branch.yml new file mode 100644 index 0000000..e95c9a0 --- /dev/null +++ b/.github/workflows/merge_branch.yml @@ -0,0 +1,54 @@ +name: merge branch + +on: + workflow_call: + inputs: + repo: + type: string + required: true + checkout_branch: + type: string + required: true + merge_from_branch: + type: string + required: true + secrets: + gh_token: + required: true + gh_user: + required: true + gh_email: + required: true + +env: + GH_TOKEN: ${{ secrets.gh_token }} + +jobs: + merge-to-main: + runs-on: ubuntu-latest + + steps: + - name: ⬇️ Checkout ${{ inputs.checkout_branch }} + uses: actions/checkout@v4 + with: + ref: ${{ inputs.checkout_branch }} + fetch-depth: 0 + + - name: 🔑 Set Bot Authentication + run: | + git config --global user.name "${{ secrets.gh_user }}" + git config --global user.email "${{ secrets.gh_email }}" + + - name: 🔀 Merge ${{ inputs.merge_from_branch }} -> ${{ inputs.checkout_branch }} + run: | + git pull origin ${{ inputs.merge_from_branch }} + git merge --no-ff origin/${{ inputs.merge_from_branch }} -m "[Automated] Merged ${{ inputs.merge_from_branch }} -> ${{ inputs.checkout_branch }}" + + # TODO implement this using gh command + - name: 🔏 Push to protected ${{ inputs.checkout_branch }} branch + uses: CasperWA/push-protected@v2.16.0 + with: + token: ${{ secrets.gh_token }} + branch: ${{ inputs.checkout_branch }} + tags: false + unprotect_reviews: false \ No newline at end of file diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index f0389a5..7a58167 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -124,7 +124,8 @@ jobs: - name: 🔀 Merge ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }} run: | - git merge origin/${{ github.ref_name }} -m "[Automated] Merged ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }}" + git pull origin ${{ github.ref_name }} + git merge --no-ff origin/${{ github.ref_name }} -m "[Automated] Merged ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }}" # TODO implement this using gh command - name: 🔏 Push to protected ${{ vars.MAIN_BRANCH }} branch diff --git a/.github/workflows/verify_latest_release.yml b/.github/workflows/verify_latest_release.yml index 67de47d..d066bd2 100644 --- a/.github/workflows/verify_latest_release.yml +++ b/.github/workflows/verify_latest_release.yml @@ -39,7 +39,7 @@ on: env: GH_REPO : ${{ inputs.repo || github.repository }} - GH_TOKEN: ${{ secrets.gh_token || false }} + GH_TOKEN: ${{ secrets.gh_token }} jobs: verify-release: From 3ad10a2e270c6c98f18250d6587702697145c219 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 17 Nov 2024 11:50:51 +0100 Subject: [PATCH 28/58] Fix parameter --- .github/workflows/release_trigger.yml | 42 +++++++++------------------ 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 7a58167..9edd700 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -67,6 +67,8 @@ jobs: repo: ${{ github.repository }} latest_release: ${{ needs.verify-latest-release.outputs.date_published }} changelog_order: ${{ vars.CHANGELOG_ORDER || false }} + secrets: + gh_token: ${{ secrets.token }} increment-version: @@ -103,38 +105,20 @@ jobs: merge-to-main: - runs-on: ubuntu-latest - needs: - - increment-version + needs: + - verify-latest-release - verify-repo-secrets - verify-repo-vars - - verify-latest-release - - steps: - - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} - uses: actions/checkout@v4 - with: - ref: ${{ vars.MAIN_BRANCH }} - fetch-depth: 0 - - - name: 🔑 Set Bot Authentication - run: | - git config --global user.name "${{ env.GH_USER }}" - git config --global user.email "${{ env.GH_EMAIL }}" - - name: 🔀 Merge ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }} - run: | - git pull origin ${{ github.ref_name }} - git merge --no-ff origin/${{ github.ref_name }} -m "[Automated] Merged ${{ github.ref_name }} -> ${{ vars.MAIN_BRANCH }}" - - # TODO implement this using gh command - - name: 🔏 Push to protected ${{ vars.MAIN_BRANCH }} branch - uses: CasperWA/push-protected@v2.16.0 - with: - token: ${{ env.GH_TOKEN }} - branch: ${{ vars.MAIN_BRANCH }} - tags: false - unprotect_reviews: false + uses: ynput/ops-repo-automation/.github/workflows/merge_branch.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + checkout_branch: ${{ vars.MAIN_BRANCH }} + merge_from_branch: ${{ github.ref_name }} + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} build-from-main: From de1dc6aa3bb0f22f6bce9db4bc0917b9e20c1230 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 17 Nov 2024 12:39:39 +0100 Subject: [PATCH 29/58] Move release verification to own workflow --- .github/workflows/initial_release.yml | 28 ++++++------------ .github/workflows/verify_release.yml | 41 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/verify_release.yml diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 4d75d30..0dfecc2 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -213,26 +213,16 @@ jobs: verify-release: - runs-on: ubuntu-latest needs: - create-release - steps: - - name: Fetch Latest Release Draft - id: fetch-latest-release-draft - run: | - current_release_name="$(gh release list --repo ${{ github.repository }} --json isDraft,name,createdAt --jq '[.[] | select(.isDraft == true)] | sort_by(.createdAt) | reverse | .[0].name')" - echo "current_release_name=$current_release_name" >> $GITHUB_OUTPUT - - - name: 🔍 Verify Release-Draft Name - id: check-release-tag - env: - latest_release_draft: ${{ steps.fetch-latest-release-draft.outputs.current_release_name }} - run: | - if [ "${{ env.INIT_VERSION }}" == "${{ env.latest_release_draft }}" ]; then - echo "::notice::Success, release-draft found with the expected name ${{ env.INIT_VERSION }}." - exit 0 - fi + uses: ynput/ops-repo-automation/.github/workflows/verify_release.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + # TODO figure out dynamic solution + expected_release_name: "0.1.0" # ${{ env.INIT_VERSION }} + draft_release: ${{ inputs.draft }} + secrets: + gh_token: ${{ secrets.token }} - echo "::error::Expected tag ${{ env.INIT_VERSION }}, but found ${{ env.latest_release_draft }}." - exit 1 \ No newline at end of file + # TODO verify tag position diff --git a/.github/workflows/verify_release.yml b/.github/workflows/verify_release.yml new file mode 100644 index 0000000..749b1e3 --- /dev/null +++ b/.github/workflows/verify_release.yml @@ -0,0 +1,41 @@ +name: verify created release + +on: + workflow_call: + inputs: + repo: + type: string + required: true + expected_release_name: + type: string + required: true + draft_release: + type: boolean + required: true + + secrets: + gh_token: + required: true + +jobs: + verify-created-release: + runs-on: ubuntu-latest + + steps: + - name: Fetch Latest Release Draft + id: fetch-latest-release + run: | + current_release_name="$(gh release list --repo ${{ inputs.repo }} --json isDraft,name,createdAt --jq '[.[] | select(.isDraft == ${{ inputs.draft_release }})] | sort_by(.createdAt) | reverse | .[0].name')" + echo "current_release_name=$current_release_name" >> $GITHUB_OUTPUT + + - name: Verify Release Name + env: + latest_release: ${{ steps.fetch-latest-release.outputs.current_release_name }} + run: | + if [ "${{ inputs.expected_release_name }}" == "${{ env.latest_release }}" ]; then + echo "::notice::Success, release$( [ '${{ inputs.draft_release }}' = 'true' ] && echo '-draft' ) found with the expected name ${{ inputs.expected_release_name }}." + exit 0 + fi + + echo "::error::Expected tag ${{ inputs.expected_release_name }}, but found ${{ env.latest_release }}." + exit 1 \ No newline at end of file From 685a9693e5b34d7dd62231741eb39dcc974067ff Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 17 Nov 2024 12:40:36 +0100 Subject: [PATCH 30/58] Update main release workflow --- .github/workflows/release_trigger.yml | 32 ++++++++------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 9edd700..e92fec3 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -274,30 +274,16 @@ jobs: verify-release: - runs-on: ubuntu-latest needs: - create-release - increment-version - env: - NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}" - steps: - - name: Fetch Latest Release Draft - id: fetch-latest-release-draft - run: | - current_release_name="$(gh release list --repo ${{ github.repository }} --json isDraft,name,createdAt --jq '[.[] | select(.isDraft == ${{ env.DRAFT }})] | sort_by(.createdAt) | reverse | .[0].name')" - echo "current_release_name=$current_release_name" >> $GITHUB_OUTPUT - - # TODO streamline to use actions if check - - name: 🔍 Check Release-Draft Name - id: check-release-tag - env: - latest_release_draft: ${{ steps.fetch-latest-release-draft.outputs.current_release_name }} - # TODO notification should show if it was a draft or is a release already - run: | - if [ "${{ env.NEXT_VERSION }}" == "${{ env.latest_release_draft }}" ]; then - echo "::notice::Success, release-draft found with the expected name ${{ env.NEXT_VERSION }}." - exit 0 - fi + uses: ynput/ops-repo-automation/.github/workflows/verify_release.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + # TODO figure out dynamic solution + expected_release_name: "0.1.0" # ${{ env.INIT_VERSION }} + draft_release: ${{ inputs.draft }} + secrets: + gh_token: ${{ secrets.token }} - echo "::error::Expected tag ${{ env.NEXT_VERSION }}, but found ${{ env.latest_release_draft }}." - exit 1 + # TODO verify tag position From 0094acc19af38f1430e70671b538d8499de54a45 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 17 Nov 2024 12:45:49 +0100 Subject: [PATCH 31/58] Update verify workflow --- .github/workflows/initial_release.yml | 2 +- .../{verify_release.yml => verify_created_release.yml} | 3 +++ .github/workflows/verify_latest_release.yml | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) rename .github/workflows/{verify_release.yml => verify_created_release.yml} (96%) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 0dfecc2..b1445f2 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -216,7 +216,7 @@ jobs: needs: - create-release - uses: ynput/ops-repo-automation/.github/workflows/verify_release.yml@refactor-release-workflow-structure + uses: ynput/ops-repo-automation/.github/workflows/verify_created_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} # TODO figure out dynamic solution diff --git a/.github/workflows/verify_release.yml b/.github/workflows/verify_created_release.yml similarity index 96% rename from .github/workflows/verify_release.yml rename to .github/workflows/verify_created_release.yml index 749b1e3..9b9121b 100644 --- a/.github/workflows/verify_release.yml +++ b/.github/workflows/verify_created_release.yml @@ -17,6 +17,9 @@ on: gh_token: required: true +env: + GH_TOKEN: ${{ secrets.gh_token }} + jobs: verify-created-release: runs-on: ubuntu-latest diff --git a/.github/workflows/verify_latest_release.yml b/.github/workflows/verify_latest_release.yml index d066bd2..74b5345 100644 --- a/.github/workflows/verify_latest_release.yml +++ b/.github/workflows/verify_latest_release.yml @@ -14,6 +14,8 @@ on: gh_token: required: true + + outputs: id: description: Release ID From bae5c2c5d0f124742d8db3eb5052603373fc37d7 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Mon, 18 Nov 2024 09:08:39 +0100 Subject: [PATCH 32/58] Update workflow reference --- .github/workflows/release_trigger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index e92fec3..7b5aeab 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -277,7 +277,7 @@ jobs: needs: - create-release - increment-version - uses: ynput/ops-repo-automation/.github/workflows/verify_release.yml@refactor-release-workflow-structure + uses: ynput/ops-repo-automation/.github/workflows/verify_created_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} # TODO figure out dynamic solution From 560c216a771ce340af28ee77c6242ba51e291f0b Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:00:38 +0100 Subject: [PATCH 33/58] Move build-from-main to its own workflow --- .github/workflows/build_from_branch.yml | 89 +++++++++++++++++++ .github/workflows/initial_release.yml | 67 +++----------- .github/workflows/release_trigger.yml | 13 +-- .../addon_repo_initial_release.yml | 1 + 4 files changed, 104 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/build_from_branch.yml diff --git a/.github/workflows/build_from_branch.yml b/.github/workflows/build_from_branch.yml new file mode 100644 index 0000000..d0f13d2 --- /dev/null +++ b/.github/workflows/build_from_branch.yml @@ -0,0 +1,89 @@ +name: merge branch + +on: + workflow_call: + inputs: + repo: + type: string + required: true + branch_name: + type: string + required: true + default: "main" + project_name: + type: string + required: true + artifact_name: + type: string + required: true + next_version: + type: string + required: false + secrets: + gh_token: + required: true + gh_user: + required: true + gh_email: + required: true + +env: + GH_TOKEN: ${{ secrets.gh_token }} + OUTPUT_DIR: "artifact" + NEXT_VERSION: "${{ inputs.next_version }}" + PROJECT_NAME: "${{ inputs.project_name }}" + ARTIFACT_NAME: "${{ inputs.artifact_name }}" + +jobs: + build-from-branch: + runs-on: ubuntu-latest + + steps: + - name: ⬇️ Checkout ${{ inputs.branch_name }} + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch_name }} + fetch-depth: 0 + submodules: true + + - name: Update package.py version to ${{ env.NEXT_VERSION }} + run: | + sed -i "s/^version = \".*\"/version = \"${{ env.NEXT_VERSION }}\"/" package.py + sed -i "s/^name = \".*\"/name = \"${{ env.PROJECT_NAME }}\"/" package.py + + - name: Create package artifacts + id: create-artifact + run: | + python create_package.py --output ${{ env.OUTPUT_DIR }} + echo "file_name=${{ env.PROJECT_NAME }}-${{ env.NEXT_VERSION }}.zip" >> $GITHUB_OUTPUT + + - name: 🔑 Set Bot Authentication + run: | + git config --global user.name "${{ secrets.gh_user }}" + git config --global user.email "${{ secrets.gh_email }}" + + - name: Add changed files from ${{ vars.MAIN_BRANCH }} + run: | + git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' + if git diff --cached --exit-code > /dev/null; then + echo "No changes to commit" + else + git commit -m "[Automated] Add generated package files from ${{ vars.MAIN_BRANCH }}" + fi + + git tag -a ${{ env.NEXT_VERSION }} -m "[Automated] Release version ${{ env.NEXT_VERSION }}" + + - name: 🔏 Push to protected ${{ vars.MAIN_BRANCH }} branch + uses: CasperWA/push-protected@v2.16.0 + with: + token: ${{ env.GH_TOKEN }} + branch: ${{ vars.MAIN_BRANCH }} + tags: false + unprotect_reviews: false + + - name: 🔼 Upload package zip artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT_NAME }} + path: | + ${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }} diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index b1445f2..b5cce38 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -74,62 +74,20 @@ jobs: build-from-main: - runs-on: ubuntu-latest needs: - merge-to-main - env: - OUTPUT_DIR: "artifact" - outputs: - artifact_file: ${{ steps.create-artifact.outputs.file_name }} - - steps: - - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} - uses: actions/checkout@v4 - with: - ref: ${{ vars.MAIN_BRANCH }} - fetch-depth: 0 - - - name: Update package.py version to ${{ env.INIT_VERSION }} - run: | - sed -i "s/^version = \".*\"/version = \"${{ env.INIT_VERSION }}\"/" package.py - sed -i "s/^name = \".*\"/name = \"${{ env.PROJECT_NAME }}\"/" package.py - - - name: Create artifacts - id: create-artifact - run: | - python create_package.py --output ${{ env.OUTPUT_DIR }} - echo "file_name=${{ env.PROJECT_NAME }}-${{ env.INIT_VERSION }}.zip" >> $GITHUB_OUTPUT - - - name: 🔑 Set Bot Authentication - run: | - git config --global user.name "${{ env.GH_USER }}" - git config --global user.email "${{ env.GH_EMAIL }}" - - - name: Add generated files from ${{ vars.MAIN_BRANCH }} - run: | - git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' - if git diff --cached --exit-code > /dev/null; then - echo "No changes to commit" - else - git commit -m "[Automated] Add generated package files from ${{ vars.MAIN_BRANCH }}" - fi - - git tag -a ${{ env.INIT_VERSION }} -m "[Automated] Release version ${{ env.INIT_VERSION }}" - - - name: 🔏 Push to protected ${{ vars.MAIN_BRANCH }} branch - uses: CasperWA/push-protected@v2.16.0 - with: - token: ${{ env.GH_TOKEN }} - branch: ${{ vars.MAIN_BRANCH }} - tags: false - unprotect_reviews: false - - name: 🔼 Upload zip artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ env.ARTIFACT_NAME }} - path: | - ${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }} + uses: ynput/ops-repo-automation/.github/workflows/build_from_branch.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + branch_name: ${{ vars.MAIN_BRANCH }} + project_name: ${{ vars.PROJECT_NAME }} + artifact_name: "${{ vars.PROJECT_NAME }}-package" + next_version: "${{ inputs.release_overwrite }}" + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} update-develop: @@ -219,8 +177,7 @@ jobs: uses: ynput/ops-repo-automation/.github/workflows/verify_created_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} - # TODO figure out dynamic solution - expected_release_name: "0.1.0" # ${{ env.INIT_VERSION }} + expected_release_name: "${{ inputs.release_overwrite }}" draft_release: ${{ inputs.draft }} secrets: gh_token: ${{ secrets.token }} diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 7b5aeab..5520636 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -28,7 +28,7 @@ env: ARTIFACT_NAME: "${{ vars.PROJECT_NAME }}-package" PROJECT_NAME: "${{ vars.PROJECT_NAME }}" REQUIRED_VARS: MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME - CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || false }}" + CHANGELOG_ORDER: "${{ vars.CHANGELOG_ORDER || '' }}" jobs: verify-latest-release: @@ -170,13 +170,6 @@ jobs: tags: false unprotect_reviews: false - # TODO remove obsolete step - - name: Get latest commit hash on ${{ vars.MAIN_BRANCH }} - id: get-commit-hash - run: | - latest_commit_hash=$(git rev-parse HEAD) - echo "latest_commit=$latest_commit" >> $GITHUB_OUTPUT - - name: 🔼 Upload package zip artifacts uses: actions/upload-artifact@v4 with: @@ -248,10 +241,8 @@ jobs: - validate-pr-information - build-from-main - increment-version - # TODO remove obsolete env var env: NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}" - RELEASE_COMMIT: "${{ needs.build-from-main.outputs.latest_commit }}" CHANGELOG: "${{ needs.validate-pr-information.outputs.changelog }}" steps: @@ -265,7 +256,7 @@ jobs: with: commit: "${{ vars.MAIN_BRANCH }}" tag: "${{ env.NEXT_VERSION }}" - body: "${{ env.CHANGELOG || false }}" + body: ${{ env.CHANGELOG || false }} generateReleaseNotes: "${{ !env.CHANGELOG }}" artifacts: | ${{ needs.build-from-main.outputs.artifact_file }} diff --git a/caller_workflows/addon_repo_initial_release.yml b/caller_workflows/addon_repo_initial_release.yml index f011ef5..b97a91f 100644 --- a/caller_workflows/addon_repo_initial_release.yml +++ b/caller_workflows/addon_repo_initial_release.yml @@ -14,6 +14,7 @@ jobs: uses: ynput/ops-repo-automation/.github/workflows/initial_release.yml@refactor-release-workflow-structure with: draft: ${{ inputs.draft }} + release_overwrite: "0.1.0" secrets: token: ${{ secrets.YNPUT_BOT_TOKEN }} email: ${{ secrets.CI_EMAIL }} From 576828d6c77fda911c3e59a186a0425c140275ad Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:08:44 +0100 Subject: [PATCH 34/58] Failure test --- .github/workflows/initial_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index b5cce38..4b639a1 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -79,7 +79,7 @@ jobs: uses: ynput/ops-repo-automation/.github/workflows/build_from_branch.yml@refactor-release-workflow-structure with: - repo: ${{ github.repository }} + # repo: ${{ github.repository }} branch_name: ${{ vars.MAIN_BRANCH }} project_name: ${{ vars.PROJECT_NAME }} artifact_name: "${{ vars.PROJECT_NAME }}-package" From f14cb9961f4bf2bbc1368169410a0ec0e76e4357 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:12:59 +0100 Subject: [PATCH 35/58] Remove fail test --- .github/workflows/initial_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 4b639a1..6d7f8f9 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -79,7 +79,7 @@ jobs: uses: ynput/ops-repo-automation/.github/workflows/build_from_branch.yml@refactor-release-workflow-structure with: - # repo: ${{ github.repository }} + repo: ${{ github.repository }} branch_name: ${{ vars.MAIN_BRANCH }} project_name: ${{ vars.PROJECT_NAME }} artifact_name: "${{ vars.PROJECT_NAME }}-package" From 36ead5d3ef83cf09a386ffa7c53ede48992daa4b Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:21:22 +0100 Subject: [PATCH 36/58] Remove latest_commit output --- .github/workflows/release_trigger.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 5520636..7fe6d7c 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -131,7 +131,6 @@ jobs: NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}" outputs: artifact_file: ${{ steps.create-artifact.outputs.file_name }} - latest_commit: ${{ steps.get-commit-hash.outputs.latest_commit}} steps: - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} From a3a0203f2f7ba4fede3d4174bf4178626818cf3d Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:46:13 +0100 Subject: [PATCH 37/58] Formatting and cleanup --- .github/workflows/build_from_branch.yml | 3 ++ .github/workflows/initial_release.yml | 2 +- .github/workflows/release_trigger.yml | 67 +++++-------------------- 3 files changed, 17 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build_from_branch.yml b/.github/workflows/build_from_branch.yml index d0f13d2..0786db5 100644 --- a/.github/workflows/build_from_branch.yml +++ b/.github/workflows/build_from_branch.yml @@ -63,6 +63,9 @@ jobs: git config --global user.email "${{ secrets.gh_email }}" - name: Add changed files from ${{ vars.MAIN_BRANCH }} + # INFO wont work in ayon-addon-action testing for initial release + # INFO due to no present changes at this point in time + # WARNING This will offset the tag by one commit if generated artifact is the only change cause it's excluded run: | git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' if git diff --cached --exit-code > /dev/null; then diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 6d7f8f9..c4cc301 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -87,7 +87,7 @@ jobs: secrets: gh_token: ${{ secrets.token }} gh_user: ${{ secrets.user }} - gh_email: ${{ secrets.email }} + gh_email: ${{ secrets.email }} update-develop: diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 7fe6d7c..2868d15 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -5,11 +5,10 @@ on: inputs: draft: type: boolean + required: false release_overwrite: type: string - release_name: - type: string - + required: false secrets: token: required: true @@ -24,7 +23,6 @@ env: GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} DRAFT: ${{ inputs.draft }} NEXT_RELEASE: ${{ inputs.release_overwrite }} - RELEASE_NAME: ${{ inputs.release_name || '' }} ARTIFACT_NAME: "${{ vars.PROJECT_NAME }}-package" PROJECT_NAME: "${{ vars.PROJECT_NAME }}" REQUIRED_VARS: MAIN_BRANCH,MINOR_BUMP_LABEL,PATCH_BUMP_LABEL,PROJECT_NAME @@ -122,60 +120,21 @@ jobs: build-from-main: - runs-on: ubuntu-latest needs: - increment-version - merge-to-main - env: - OUTPUT_DIR: "artifact" - NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}" - outputs: - artifact_file: ${{ steps.create-artifact.outputs.file_name }} - - steps: - - name: ⬇️ Checkout ${{ vars.MAIN_BRANCH }} - uses: actions/checkout@v4 - with: - ref: ${{ vars.MAIN_BRANCH }} - fetch-depth: 0 - submodules: true - - - name: Update package.py version to ${{ env.NEXT_VERSION }} - run: | - sed -i "s/^version = \".*\"/version = \"${{ env.NEXT_VERSION }}\"/" package.py - sed -i "s/^name = \".*\"/name = \"${{ env.PROJECT_NAME }}\"/" package.py - - - name: Create package artifacts - id: create-artifact - run: | - python create_package.py --output ${{ env.OUTPUT_DIR }} - echo "file_name=${{ env.PROJECT_NAME }}-${{ env.NEXT_VERSION }}.zip" >> $GITHUB_OUTPUT - - - name: 🔑 Set Bot Authentication - run: | - git config --global user.name "${{ env.GH_USER }}" - git config --global user.email "${{ env.GH_EMAIL }}" - - - name: Add changed files from ${{ vars.MAIN_BRANCH }} - run: | - git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' - git commit -m "[Automated] Add generated package files to ${{ vars.MAIN_BRANCH }}" - - - name: 🔏 Push to protected ${{ vars.MAIN_BRANCH }} branch - uses: CasperWA/push-protected@v2.16.0 - with: - token: ${{ env.GH_TOKEN }} - branch: ${{ vars.MAIN_BRANCH }} - tags: false - unprotect_reviews: false - - - name: 🔼 Upload package zip artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ env.ARTIFACT_NAME }} - path: | - ${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }} + uses: ynput/ops-repo-automation/.github/workflows/build_from_branch.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + branch_name: ${{ vars.MAIN_BRANCH }} + project_name: ${{ vars.PROJECT_NAME }} + artifact_name: "${{ vars.PROJECT_NAME }}-package" + next_version: "${{ inputs.release_overwrite || needs.increment-version.outputs.next-version }}" + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} update-develop: runs-on: ubuntu-latest From 499a84eff1cded0d0dfaf8ff84309ecd3a042c0c Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:51:40 +0100 Subject: [PATCH 38/58] Add dependency --- .github/workflows/release_trigger.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 2868d15..8bfd0cb 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -64,7 +64,7 @@ jobs: with: repo: ${{ github.repository }} latest_release: ${{ needs.verify-latest-release.outputs.date_published }} - changelog_order: ${{ vars.CHANGELOG_ORDER || false }} + changelog_order: ${{ vars.CHANGELOG_ORDER || '' }} secrets: gh_token: ${{ secrets.token }} @@ -104,6 +104,7 @@ jobs: merge-to-main: needs: + - increment-version - verify-latest-release - verify-repo-secrets - verify-repo-vars From 3a42d637c338a96984523c6511162d04b9dc1f40 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 10:56:01 +0100 Subject: [PATCH 39/58] Add notes --- NOTES.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 NOTES.md diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..90d94e9 --- /dev/null +++ b/NOTES.md @@ -0,0 +1,5 @@ +## Known issue for [testing environment](https://github.com/ynput/ayon-addon-action-testing) + +* package.py wont create any additional files in this repo +* Therefore no changes happen in this step and no commit +* Version tag gets set one commit behind From d39974ba07067260744ef4b3e994d45485b59a8b Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 12:57:50 +0100 Subject: [PATCH 40/58] Move update_branch logic to own workflow --- .github/workflows/build_from_branch.yml | 10 +++- .github/workflows/initial_release.yml | 62 ++++---------------- .github/workflows/release_trigger.yml | 4 +- .github/workflows/update_branch.yml | 78 +++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/update_branch.yml diff --git a/.github/workflows/build_from_branch.yml b/.github/workflows/build_from_branch.yml index 0786db5..bcfe4d3 100644 --- a/.github/workflows/build_from_branch.yml +++ b/.github/workflows/build_from_branch.yml @@ -1,4 +1,4 @@ -name: merge branch +name: Build from Branch on: workflow_call: @@ -27,6 +27,11 @@ on: gh_email: required: true + outputs: + artifact_file: + description: List of unique labels + value: ${{ jobs.build-from-branch.outputs.artifact_file }} + env: GH_TOKEN: ${{ secrets.gh_token }} OUTPUT_DIR: "artifact" @@ -38,6 +43,9 @@ jobs: build-from-branch: runs-on: ubuntu-latest + outputs: + artifact_file: ${{ steps.create-artifact.outputs.file_name }} + steps: - name: ⬇️ Checkout ${{ inputs.branch_name }} uses: actions/checkout@v4 diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index c4cc301..88c8fcb 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -91,61 +91,19 @@ jobs: update-develop: - runs-on: ubuntu-latest - env: - OUTPUT_DIR: "artifact" needs: - build-from-main - steps: - - name: ⬇️ Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - with: - ref: ${{ github.ref_name }} - - - name: 🔀 Merge ${{ vars.MAIN_BRANCH }} -> ${{ github.ref_name }} - run: | - git pull origin ${{ vars.MAIN_BRANCH }} - git merge --no-ff origin/${{ vars.MAIN_BRANCH }} -m "[Automated] Merged ${{ vars.MAIN_BRANCH }} -> ${{ github.ref_name }}" - - - name: Read version from package.py - id: package-version - run: | - version=$(sed -n 's/^version *= *"\(.*\)"/\1/p' package.py) - echo "version=$version" >> $GITHUB_OUTPUT - - - name: Update package version for ${{ github.ref_name }} - id: develop-version - run: | - echo "develop_version=${{ env.INIT_VERSION }}-dev" >> $GITHUB_OUTPUT - - - name: Update package version for - run: | - sed -i "s/^version = \".*\"/version = \"${{ steps.develop-version.outputs.develop_version }}\"/" package.py - - - name: Create artifacts - id: create-artifact - run: | - python create_package.py --output ${{ env.OUTPUT_DIR }} - - - name: 🔑 Set Bot Authentication - run: | - git config --global user.email "${{ env.GH_EMAIL }}" - git config --global user.name "${{ env.GH_USER }}" - - - name: Update package.py version to ${{ steps.develop-version.outputs.develop_version }} - if: ${{ steps.package-version.outputs.version != steps.develop-version.outputs.develop_version }} - run: | - git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' - git commit -m "[Automated] Update version in package.py for develop" - - - name: 🔏 Push to protected ${{ github.ref_name }} branch - uses: CasperWA/push-protected@v2.16.0 - with: - token: ${{ env.GH_TOKEN }} - branch: ${{ github.ref_name }} - tags: false - unprotect_reviews: false + uses: ynput/ops-repo-automation/.github/workflows/update_branch.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + checkout_branch: ${{ github.ref_name }} + update_from_branch: ${{ vars.MAIN_BRANCH }} + next_version: "${{ inputs.release_overwrite }}" + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} create-release: diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 8bfd0cb..3ba4098 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -227,11 +227,11 @@ jobs: needs: - create-release - increment-version + uses: ynput/ops-repo-automation/.github/workflows/verify_created_release.yml@refactor-release-workflow-structure with: repo: ${{ github.repository }} - # TODO figure out dynamic solution - expected_release_name: "0.1.0" # ${{ env.INIT_VERSION }} + expected_release_name: ${{ needs.increment-version.outputs.next-version }} draft_release: ${{ inputs.draft }} secrets: gh_token: ${{ secrets.token }} diff --git a/.github/workflows/update_branch.yml b/.github/workflows/update_branch.yml new file mode 100644 index 0000000..415ae33 --- /dev/null +++ b/.github/workflows/update_branch.yml @@ -0,0 +1,78 @@ +name: Update Branch + +on: + workflow_call: + inputs: + repo: + type: string + required: true + checkout_branch: + type: string + required: true + update_from_branch: + type: string + required: true + next_version: + type: string + required: true + secrets: + gh_token: + required: true + gh_user: + required: true + gh_email: + required: true + +env: + GH_TOKEN: ${{ secrets.gh_token }} + OUTPUT_DIR: "artifact" + NEXT_PACKAGE_VERSION: "${{ inputs.next_version }}+dev" + +jobs: + update-branch: + runs-on: ubuntu-latest + + steps: + - name: ⬇️ Checkout ${{ inputs.checkout_branch }} + uses: actions/checkout@v4 + with: + ref: ${{ inputs.checkout_branch }} + + - name: 🔀 Merge ${{ inputs.update_from_branch }} -> ${{ inputs.checkout_branch }} + run: | + git pull origin ${{ inputs.update_from_branch }} + git merge --no-ff origin/${{ inputs.update_from_branch }} -m "[Automated] Merged ${{ inputs.update_from_branch }} -> ${{ inputs.checkout_branch }}" + + - name: Read version from package.py + id: package-version + run: | + version=$(sed -n 's/^version *= *"\(.*\)"/\1/p' package.py) + echo "version=$version" >> $GITHUB_OUTPUT + + - name: Update package version for ${{ inputs.checkout_branch }} to ${{ inputs.next_version }} + run: | + sed -i "s/^version = \".*\"/version = \"${{ env.NEXT_PACKAGE_VERSION }}\"/" package.py + + - name: Create artifacts + id: create-artifact + run: | + python create_package.py --output ${{ env.OUTPUT_DIR }} + + - name: 🔑 Set Bot Authentication + run: | + git config --global user.name "${{ secrets.gh_user }}" + git config --global user.email "${{ secrets.gh_email }}" + + - name: Commit generated files + if: ${{ steps.package-version.outputs.version != inputs.next_version }} + run: | + git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' + git commit -m "[Automated] Update version in package.py for develop" + + - name: 🔏 Push to protected ${{ github.ref_name }} branch + uses: CasperWA/push-protected@v2.16.0 + with: + token: ${{ env.GH_TOKEN }} + branch: ${{ github.ref_name }} + tags: false + unprotect_reviews: false \ No newline at end of file From 7d05df0c0adda139d024fe5618c240c277f5633c Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 12:58:25 +0100 Subject: [PATCH 41/58] Remove obsolete white space --- .github/workflows/initial_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 88c8fcb..6c46e2d 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -96,7 +96,7 @@ jobs: uses: ynput/ops-repo-automation/.github/workflows/update_branch.yml@refactor-release-workflow-structure with: - repo: ${{ github.repository }} + repo: ${{ github.repository }} checkout_branch: ${{ github.ref_name }} update_from_branch: ${{ vars.MAIN_BRANCH }} next_version: "${{ inputs.release_overwrite }}" From 3699605a1fce239a337b71ed3e0830928bea537c Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 12:58:51 +0100 Subject: [PATCH 42/58] Update formatting of inputs --- .github/workflows/initial_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 6c46e2d..5677894 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -99,7 +99,7 @@ jobs: repo: ${{ github.repository }} checkout_branch: ${{ github.ref_name }} update_from_branch: ${{ vars.MAIN_BRANCH }} - next_version: "${{ inputs.release_overwrite }}" + next_version: ${{ inputs.release_overwrite }} secrets: gh_token: ${{ secrets.token }} gh_user: ${{ secrets.user }} From b647311271fadfa5b29e3e33bd2e44f3e003900a Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sat, 23 Nov 2024 13:07:43 +0100 Subject: [PATCH 43/58] Update to package version instead --- .github/workflows/update_branch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_branch.yml b/.github/workflows/update_branch.yml index 415ae33..fa2c32a 100644 --- a/.github/workflows/update_branch.yml +++ b/.github/workflows/update_branch.yml @@ -49,7 +49,7 @@ jobs: version=$(sed -n 's/^version *= *"\(.*\)"/\1/p' package.py) echo "version=$version" >> $GITHUB_OUTPUT - - name: Update package version for ${{ inputs.checkout_branch }} to ${{ inputs.next_version }} + - name: Update package version for ${{ inputs.checkout_branch }} to ${{ env.NEXT_PACKAGE_VERSION }} run: | sed -i "s/^version = \".*\"/version = \"${{ env.NEXT_PACKAGE_VERSION }}\"/" package.py @@ -64,7 +64,7 @@ jobs: git config --global user.email "${{ secrets.gh_email }}" - name: Commit generated files - if: ${{ steps.package-version.outputs.version != inputs.next_version }} + if: ${{ steps.package-version.outputs.version != env.NEXT_PACKAGE_VERSION }} run: | git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' git commit -m "[Automated] Update version in package.py for develop" From a87387f82e998067a98773fc9cdda1efaf2fd8c3 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 10:27:54 +0100 Subject: [PATCH 44/58] Force tag to string --- .github/workflows/initial_release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 5677894..50fb5ea 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -21,7 +21,6 @@ env: GH_TOKEN: ${{ secrets.token || secrets.YNPUT_BOT_TOKEN}} GH_USER: ${{ secrets.user || secrets.CI_USER }} GH_EMAIL: ${{ secrets.email || secrets.CI_EMAIL }} - INIT_VERSION: "0.1.0" RELEASE_NAME: ${{ inputs.name || '' }} DRAFT: ${{ inputs.draft }} ARTIFACT_NAME: "${{ vars.PROJECT_NAME }}-package" @@ -121,7 +120,7 @@ jobs: uses: ncipollo/release-action@v1 with: commit: ${{ vars.MAIN_BRANCH }} - tag: "${{ env.INIT_VERSION }}" + tag: "${{ inputs.release_overwrite }}" generateReleaseNotes: true artifacts: ${{ needs.build-from-main.outputs.artifact_file }} token: ${{ env.GH_TOKEN }} From b8f8ce0f1e4fc4c85ada4388f46c7d5da46a051d Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 10:50:14 +0100 Subject: [PATCH 45/58] Extend reset workflow to disable drafts --- .github/workflows/reset_test_repo.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index d50c1cf..a86b13c 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -248,7 +248,7 @@ jobs: steps: - name: Create GitHub Release run: | - gh workflow run initial_release.yml --repo ${{ env.TARGET_REPO }} + gh workflow run initial_release.yml --repo ${{ env.TARGET_REPO }} --inputs draft=false - name: Poll for Draft Release # TODO check if draft release creation emmits a signal or something to avoid this kind of pulling @@ -267,11 +267,6 @@ jobs: fi done - - name: Publish Release - if: steps.poll-release.outputs.release_tag - run: | - gh release edit ${{ steps.poll-release.outputs.release_tag }} --draft=false --repo ${{ env.TARGET_REPO }} - create-dummy-prs: runs-on: ubuntu-latest From cbf0e127c7e4b82992042b18df36eaab39245233 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 10:51:10 +0100 Subject: [PATCH 46/58] Add comment --- .github/workflows/initial_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 50fb5ea..faf3483 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -120,7 +120,7 @@ jobs: uses: ncipollo/release-action@v1 with: commit: ${{ vars.MAIN_BRANCH }} - tag: "${{ inputs.release_overwrite }}" + tag: "${{ inputs.release_overwrite }}" # string conversion is mandatory here generateReleaseNotes: true artifacts: ${{ needs.build-from-main.outputs.artifact_file }} token: ${{ env.GH_TOKEN }} From bdb0560d2191f32e55ecd11308150a5225c13732 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 10:56:01 +0100 Subject: [PATCH 47/58] Update workflow parameter name --- .github/workflows/reset_test_repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index a86b13c..1aa1085 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -248,7 +248,7 @@ jobs: steps: - name: Create GitHub Release run: | - gh workflow run initial_release.yml --repo ${{ env.TARGET_REPO }} --inputs draft=false + gh workflow run initial_release.yml --repo ${{ env.TARGET_REPO }} --field draft=false - name: Poll for Draft Release # TODO check if draft release creation emmits a signal or something to avoid this kind of pulling From b9a59542dcf680ccf17677f1a4695e35e7ce28d6 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 11:10:10 +0100 Subject: [PATCH 48/58] Push tags when building from main --- .github/workflows/build_from_branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_from_branch.yml b/.github/workflows/build_from_branch.yml index bcfe4d3..f8dd08f 100644 --- a/.github/workflows/build_from_branch.yml +++ b/.github/workflows/build_from_branch.yml @@ -89,7 +89,7 @@ jobs: with: token: ${{ env.GH_TOKEN }} branch: ${{ vars.MAIN_BRANCH }} - tags: false + tags: true unprotect_reviews: false - name: 🔼 Upload package zip artifacts From 5b5cdd0208738ba96b328027efdad6023019d289 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 11:23:12 +0100 Subject: [PATCH 49/58] Remove main branch ref for release creation from initial release workflow --- .github/workflows/initial_release.yml | 1 - .github/workflows/verify_created_release.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index faf3483..04b7285 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -119,7 +119,6 @@ jobs: - name: 🚀 Create Github Release uses: ncipollo/release-action@v1 with: - commit: ${{ vars.MAIN_BRANCH }} tag: "${{ inputs.release_overwrite }}" # string conversion is mandatory here generateReleaseNotes: true artifacts: ${{ needs.build-from-main.outputs.artifact_file }} diff --git a/.github/workflows/verify_created_release.yml b/.github/workflows/verify_created_release.yml index 9b9121b..02c6b88 100644 --- a/.github/workflows/verify_created_release.yml +++ b/.github/workflows/verify_created_release.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - - name: Fetch Latest Release Draft + - name: Fetch Latest Release id: fetch-latest-release run: | current_release_name="$(gh release list --repo ${{ inputs.repo }} --json isDraft,name,createdAt --jq '[.[] | select(.isDraft == ${{ inputs.draft_release }})] | sort_by(.createdAt) | reverse | .[0].name')" From 76dc62f31860ecadd8575b459f5dad4c2d6337ca Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 11:28:59 +0100 Subject: [PATCH 50/58] Update live creation --- .github/workflows/initial_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/initial_release.yml b/.github/workflows/initial_release.yml index 04b7285..6af6ed7 100644 --- a/.github/workflows/initial_release.yml +++ b/.github/workflows/initial_release.yml @@ -119,11 +119,11 @@ jobs: - name: 🚀 Create Github Release uses: ncipollo/release-action@v1 with: - tag: "${{ inputs.release_overwrite }}" # string conversion is mandatory here + tag: ${{ inputs.release_overwrite }} generateReleaseNotes: true artifacts: ${{ needs.build-from-main.outputs.artifact_file }} token: ${{ env.GH_TOKEN }} - draft: true + draft: ${{ inputs.draft }} verify-release: From dc2dbd3cc173cc5cd7cd2c7e94cdb152b14afe9e Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 11:56:17 +0100 Subject: [PATCH 51/58] Update dummy Prs --- .github/workflows/reset_test_repo.yml | 83 +++++++++++---------------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index 1aa1085..39c0d4d 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -294,31 +294,24 @@ jobs: git push -u origin test_feature01 pr_body=" - # Date file added - - ## Summary - - Got a date file included - - ## Root Cause Analysis - - [Issue Link](https://github.com/ynput/ci-testing/blob/develop/.github/ISSUE_TEMPLATE/bug_report.yml) - - ## Changelog - - * Add date file - * Commit it - * Fix no date file - - ## Testing Strategy - - Tested all the way. - - ## Checklist - - * [x] The fix has been locally tested - * [x] New unit tests have been added to prevent future regressions - * [x] The documentation has been updated if necessary + ## Changelog Description + Add temp directory for deadline submission so that it would not error out during deadline submission. + Continuity of https://github.com/ynput/ayon-blender/pull/17 + *Support different system platform + + + ## Additional info + n/a + + + ## Testing notes: + + 1. Launch Blender + 2. Create Render Instance + 3. Publish + 4. If validate render output for deadline errors out, make sure you perform repair action + 5. Publish + 6. It should be rendered successfully. " gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature01 --title "Add date file" --body "$pr_body" --label "bugfix" --assignee "${{ github.actor }}" @@ -336,30 +329,20 @@ jobs: git push -u origin test_feature02 pr_body=" - # Memory usage check added - - ## Summary - - Got a check for memory usage implemented - - ## Root Cause Analysis - - [Issue Link](https://github.com/ynput/ci-testing/blob/develop/.github/ISSUE_TEMPLATE/bug_report.yml) - - ## Changelog - - * Add text file - * Commit it the memory check - * Fix no memory usage file - - ## Testing Strategy - - Tested all the way. - - ## Checklist - - * [x] The fix has been locally tested - * [x] New unit tests have been added to prevent future regressions - * [x] The documentation has been updated if necessary + ## Changelog Description + + + - Prototype loading of USD references into a Maya USD proxy while keeping it managed by the pipeline + - Prototype loading of Maya references into a Maya USD proxy while keeping it managed by the pipeline + + ## Additional info + + + Separated from #2 + + ## Testing notes: + + 1. Loading of the USD data should work as intended into Maya USD Proxy Shapes. + 2. Managing (updating) and removal via scene inventory should also do what is expected. " gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature02 --title "Add mem file" --body "$pr_body" --label "enhancement" --assignee "${{ github.actor }}" From eefec7be18cbe7775e4cc6e19d887484a85c289b Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 11:58:38 +0100 Subject: [PATCH 52/58] Update release workflow --- .github/workflows/release_trigger.yml | 60 +++++---------------------- 1 file changed, 10 insertions(+), 50 deletions(-) diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml index 3ba4098..e1d38df 100644 --- a/.github/workflows/release_trigger.yml +++ b/.github/workflows/release_trigger.yml @@ -138,60 +138,20 @@ jobs: gh_email: ${{ secrets.email }} update-develop: - runs-on: ubuntu-latest needs: - build-from-main - increment-version - env: - OUTPUT_DIR: "artifact" - NEXT_VERSION: "${{ needs.increment-version.outputs.next-version }}" - NEXT_PACKAGE_VERSION: "${{ needs.increment-version.outputs.next-version }}+dev" - - steps: - - name: ⬇️ Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - with: - ref: ${{ github.ref_name }} - - - name: 🔀 Merge ${{ vars.MAIN_BRANCH }} -> ${{ github.ref_name }} - run: | - git pull origin ${{ vars.MAIN_BRANCH }} - git merge --no-ff origin/${{ vars.MAIN_BRANCH }} -m "[Automated] Merged ${{ vars.MAIN_BRANCH }} -> ${{ github.ref_name }}" - - # ? Still requried ? - - name: Read version from package.py - id: package-version - run: | - version=$(sed -n 's/^version *= *"\(.*\)"/\1/p' package.py) - echo "version=$version" >> $GITHUB_OUTPUT - - - name: Update package version for ${{ github.ref_name }} to ${{ env.NEXT_PACKAGE_VERSION }} - run: | - sed -i "s/^version = \".*\"/version = \"${{ env.NEXT_PACKAGE_VERSION }}\"/" package.py - - - name: Create artifacts - id: create-artifact - run: | - python create_package.py --output ${{ env.OUTPUT_DIR }} - - - name: 🔑 Set Bot Authentication - run: | - git config --global user.email "${{ env.GH_EMAIL }}" - git config --global user.name "${{ env.GH_USER }}" - - name: Commit generated files - if: ${{ steps.package-version.outputs.version != env.NEXT_PACKAGE_VERSION }} - run: | - git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}' - git commit -m "[Automated] Update version in package.py for develop" - - - name: 🔏 Push to protected ${{ github.ref_name }} branch - uses: CasperWA/push-protected@v2.16.0 - with: - token: ${{ env.GH_TOKEN }} - branch: ${{ github.ref_name }} - tags: false - unprotect_reviews: false + uses: ynput/ops-repo-automation/.github/workflows/update_branch.yml@refactor-release-workflow-structure + with: + repo: ${{ github.repository }} + checkout_branch: ${{ github.ref_name }} + update_from_branch: ${{ vars.MAIN_BRANCH }} + next_version: "${{ needs.increment-version.outputs.next-version }}" + secrets: + gh_token: ${{ secrets.token }} + gh_user: ${{ secrets.user }} + gh_email: ${{ secrets.email }} create-release: From 1daca60da908b1ece4483830630045ec38c0b7c4 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Sun, 24 Nov 2024 12:27:08 +0100 Subject: [PATCH 53/58] Extend TODOs --- NOTES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NOTES.md b/NOTES.md index 90d94e9..b80f4c2 100644 --- a/NOTES.md +++ b/NOTES.md @@ -3,3 +3,10 @@ * package.py wont create any additional files in this repo * Therefore no changes happen in this step and no commit * Version tag gets set one commit behind + +## Testing notes + +* Test version overwrite +* Test PR-label validation +* Test missing repo vars +* Add tag to hash verification to release workflow From 1108eb036cc3a78e5dd78b1761609798048f6d6d Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Mon, 25 Nov 2024 09:05:46 +0100 Subject: [PATCH 54/58] Reorder testing notes --- NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOTES.md b/NOTES.md index b80f4c2..086e022 100644 --- a/NOTES.md +++ b/NOTES.md @@ -6,7 +6,7 @@ ## Testing notes -* Test version overwrite * Test PR-label validation +* Test version overwrite * Test missing repo vars * Add tag to hash verification to release workflow From 4fb2ebac0e73f68bad150b45b0987704c77e6bf0 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Mon, 25 Nov 2024 15:42:01 +0100 Subject: [PATCH 55/58] Update label names --- .github/workflows/reset_test_repo.yml | 14 +++++++------- NOTES.md | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index 39c0d4d..9d78dde 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -94,18 +94,18 @@ jobs: - name: Set repo variables run: | - gh variable set PATCH_BUMP_LABEL --body "bugfix" --repo ${{ env.TARGET_REPO }} - gh variable set MINOR_BUMP_LABEL --body "feature, enhancement" --repo ${{ env.TARGET_REPO }} + gh variable set PATCH_BUMP_LABEL --body "type: bugfix" --repo ${{ env.TARGET_REPO }} + gh variable set MINOR_BUMP_LABEL --body "type: feature, type: enhancement" --repo ${{ env.TARGET_REPO }} gh variable set MAIN_BRANCH --body "main" --repo ${{ env.TARGET_REPO }} gh variable set PROJECT_NAME --body ${{ env.TARGET_REPO_PROJECT_NAME }} --repo ${{ env.TARGET_REPO }} - gh variable set CHANGELOG_ORDER --body "feature,enhancement,bugfix,refactor,docs,test,pr" --repo ${{ env.TARGET_REPO }} + gh variable set CHANGELOG_ORDER --body "type: feature,type: enhancement,type: bugfix,refactor,docs,test,pr" --repo ${{ env.TARGET_REPO }} echo "$(gh variable list --repo ${{ env.TARGET_REPO }})" - name: Add repo labels run: | - gh label create "feature" --color "#008672" --description "New functionality which is not present so far" --repo ${{ env.TARGET_REPO }} - gh label create "bugfix" --color "#f96713" --description "Something got fixed" --repo ${{ env.TARGET_REPO }} + gh label create "type: feature" --color "#008672" --description "New functionality which is not present so far" --repo ${{ env.TARGET_REPO }} + gh label create "type: bugfix" --color "#f96713" --description "Something got fixed" --repo ${{ env.TARGET_REPO }} echo "$(gh label list --repo ${{ env.TARGET_REPO }})" @@ -313,7 +313,7 @@ jobs: 5. Publish 6. It should be rendered successfully. " - gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature01 --title "Add date file" --body "$pr_body" --label "bugfix" --assignee "${{ github.actor }}" + gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature01 --title "Add date file" --body "$pr_body" --label "type: bugfix" --assignee "${{ github.actor }}" - name: Create second feature branch run: | @@ -345,4 +345,4 @@ jobs: 1. Loading of the USD data should work as intended into Maya USD Proxy Shapes. 2. Managing (updating) and removal via scene inventory should also do what is expected. " - gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature02 --title "Add mem file" --body "$pr_body" --label "enhancement" --assignee "${{ github.actor }}" + gh pr create --base ${{ env.DEFAULT_BRANCH }} --head test_feature02 --title "Add mem file" --body "$pr_body" --label "type: enhancement" --assignee "${{ github.actor }}" diff --git a/NOTES.md b/NOTES.md index 086e022..62a774b 100644 --- a/NOTES.md +++ b/NOTES.md @@ -6,7 +6,6 @@ ## Testing notes -* Test PR-label validation * Test version overwrite * Test missing repo vars * Add tag to hash verification to release workflow From 68b2f89df363be69f7677405c53e6fe1473a54ca Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Mon, 25 Nov 2024 15:56:55 +0100 Subject: [PATCH 56/58] Update type enhancement --- .github/workflows/reset_test_repo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index 9d78dde..8344248 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -105,6 +105,7 @@ jobs: - name: Add repo labels run: | gh label create "type: feature" --color "#008672" --description "New functionality which is not present so far" --repo ${{ env.TARGET_REPO }} + gh label create "type: enhancement" --color "#b9f29d" --description "Something got fixed" --repo ${{ env.TARGET_REPO }} gh label create "type: bugfix" --color "#f96713" --description "Something got fixed" --repo ${{ env.TARGET_REPO }} echo "$(gh label list --repo ${{ env.TARGET_REPO }})" From b42f0daf583a9633b8b87431c79be4a66165114a Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Mon, 25 Nov 2024 16:16:44 +0100 Subject: [PATCH 57/58] Update notes Add emotes --- .github/workflows/reset_test_repo.yml | 2 +- NOTES.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/reset_test_repo.yml b/.github/workflows/reset_test_repo.yml index 8344248..966bc76 100644 --- a/.github/workflows/reset_test_repo.yml +++ b/.github/workflows/reset_test_repo.yml @@ -98,7 +98,7 @@ jobs: gh variable set MINOR_BUMP_LABEL --body "type: feature, type: enhancement" --repo ${{ env.TARGET_REPO }} gh variable set MAIN_BRANCH --body "main" --repo ${{ env.TARGET_REPO }} gh variable set PROJECT_NAME --body ${{ env.TARGET_REPO_PROJECT_NAME }} --repo ${{ env.TARGET_REPO }} - gh variable set CHANGELOG_ORDER --body "type: feature,type: enhancement,type: bugfix,refactor,docs,test,pr" --repo ${{ env.TARGET_REPO }} + gh variable set CHANGELOG_ORDER --body "type: feature(🎉),type: enhancement(💚),type: bugfix(🐛),refactor,docs,test,pr" --repo ${{ env.TARGET_REPO }} echo "$(gh variable list --repo ${{ env.TARGET_REPO }})" diff --git a/NOTES.md b/NOTES.md index 62a774b..7e73787 100644 --- a/NOTES.md +++ b/NOTES.md @@ -6,6 +6,5 @@ ## Testing notes -* Test version overwrite * Test missing repo vars * Add tag to hash verification to release workflow From ce218d7dbfb51f48909e9e05946664d85c549dd3 Mon Sep 17 00:00:00 2001 From: PhilNewm Date: Mon, 25 Nov 2024 16:26:53 +0100 Subject: [PATCH 58/58] Update testing notes --- NOTES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/NOTES.md b/NOTES.md index 7e73787..22f1426 100644 --- a/NOTES.md +++ b/NOTES.md @@ -6,5 +6,4 @@ ## Testing notes -* Test missing repo vars * Add tag to hash verification to release workflow