From a72c5922dab5795546531f2b4d4f17c6094621c7 Mon Sep 17 00:00:00 2001 From: tuntoja Date: Thu, 29 Feb 2024 14:13:07 +0100 Subject: [PATCH 1/5] udpate release workflow --- .github/workflows/release.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85e89a1cc74..7fcd32142f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,9 +20,22 @@ on: jobs: release: - if: github.event.pull_request.merged == true && (github.base_ref == 'master' || github.base_ref == '[2-9][0-9].[0-9][0-9].x') + if: ${{ github.event.pull_request.merged == true }} runs-on: ubuntu-22.04 steps: + - name: Check base_ref + run: | + set -eu + # Check if github.base_ref is either master or any of the supported version ones + # This must never run on any other than master and supported version base_ref + if [[ "${{ github.base_ref }}" == 'master' || "${{ github.base_ref }}" =~ ^[2-9][0-9].[0-9][0-9].x ]];then + echo "[DEBUG] base_ref is valid: ${{ github.base_ref }}" + else + echo "[DEBUG] base_ref is not valid (${{ github.base_ref }}), exiting." + exit 1 + fi + shell: bash + - name: Checkout sources uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: @@ -34,6 +47,7 @@ jobs: with: github_ref_name: ${{ github.head_ref || github.ref_name }} jira_project_id: ${{ secrets.JIRA_PROJECT_ID }} - jira_webhook_url: ${{ secrets.JIRA_RELEASE_WEBHOOK }} jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} + jira_webhook_url: ${{ secrets.JIRA_RELEASE_WEBHOOK }} + module_name: ${{ env.module }} From e4ea5abb8763f2aa6e7856ce2389dfa5585e066d Mon Sep 17 00:00:00 2001 From: tuntoja Date: Thu, 29 Feb 2024 14:28:10 +0100 Subject: [PATCH 2/5] udpate release action --- .github/actions/release/action.yml | 34 ++++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 7b427426444..4df014979b7 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -4,18 +4,21 @@ inputs: github_ref_name: description: "Github ref name" required: true + module_name: + description: "The package module name" + required: true + jira_api_token: + description: "Token to authenticate to Jira" + required: true + jira_user_email: + description: "Email linked to token" + required: true jira_project_id: description: "Jira project id to create release" required: true jira_webhook_url: description: "Jira release webhook" required: true - jira_user_email: - description: "Jira user email" - required: true - jira_api_token: - description: "Jira api token" - required: true runs: using: "composite" @@ -53,12 +56,11 @@ runs: PREVIOUS_STABLE_TAGS+=($(git tag -l --sort=-version:refname "$component-$CURRENT_STABLE_BRANCH_MAJOR_VERSION*" | head -n 1)) # New stable tags array NEW_STABLE_TAGS+=("$component-$MAJOR_VERSION.$MINOR_VERSION") - done echo "Previous releases were: ${PREVIOUS_STABLE_TAGS[*]}" echo "New releases are: ${NEW_STABLE_TAGS[*]}" - # Check that NEW_STABLE_TAGS are fully different from PREVIOUS_STABLE_TAGS + # TODO: Check that NEW_STABLE_TAGS are fully different from PREVIOUS_STABLE_TAGS # re use the part from check version ?? # or use the check-version action after turning this release action into a real workflow ? @@ -81,7 +83,7 @@ runs: if [ -z $(git tag --list "$TAG" | head -n 1) ]; then git tag -a "$TAG" -m "$TAG" git push --follow-tags - echo "::notice::Tagging branch with $TAG." + echo "::notice::Tagging stable branch with $TAG." else echo "::error::Release tag $TAG already exists, exiting." exit 1 @@ -95,12 +97,12 @@ runs: echo "Installing GH CLI." if ! command -v gh &> /dev/null; then echo "Installing GH CLI." - type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) + type -p curl >/dev/null || (sudo apt-get update && sudo apt-get install curl -y) curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null - sudo apt update - sudo apt install gh -y + sudo apt-get update + sudo apt-get install gh -y else echo "GH CLI is already installed." fi @@ -108,7 +110,7 @@ runs: # Create GITHUB release for each release components echo "Creating GITHUB releases." for TAG in ${NEW_STABLE_TAGS[@]}; do - echo "::notice::Creating release with title $TAG for tag $TAG." + echo "Creating GITHUB release with title $TAG for tag $TAG." gh release create $TAG --target "${{ inputs.github_ref_name }} --title "$TAG" --verify-tag done shell: bash @@ -117,6 +119,10 @@ runs: run: | set -eu + # Call JIRA to provide new jira versions to create + # Webhook url + JIRA_INCOMING_WEBHOOK="${{ inputs.jira_webhook_url }}" + # Rebuild NEW_STABLE_TAGS as an array for i in ${NEW_STABLE_TAGS[@]}; do NEW_RELEASE_TAGS+=("$i") @@ -179,7 +185,7 @@ runs: # DEBUG echo "JSON_TAGS: \r\n$JSON_TAGS" echo "JSON_VERSION_INFO: $JSON_VERSION_INFO" - echo "Sending to JIRA AUTOMATION: \r\n$RELEASE_JSON" + echo "Sending to JIRA automation: \r\n$RELEASE_JSON" # Call jira webhook to trigger the communication workflow # and provide versions data for communication From dc5b5ced47b227cba1b3cdd14c7bfc62d651b5e4 Mon Sep 17 00:00:00 2001 From: tuntoja Date: Fri, 1 Mar 2024 09:33:53 +0100 Subject: [PATCH 3/5] add feedbacks --- .github/actions/release/action.yml | 5 +---- .github/workflows/release.yml | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 4df014979b7..43b85fb70bb 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -4,9 +4,6 @@ inputs: github_ref_name: description: "Github ref name" required: true - module_name: - description: "The package module name" - required: true jira_api_token: description: "Token to authenticate to Jira" required: true @@ -29,7 +26,7 @@ runs: - name: Get released versions for components run: | set -eu - COMPONENTS_RELEASED=() + COMPONENTS_OSS=("centreon-awie" "centreon-dsm" "centreon-gorgone" "centreon-ha" "centreon-open-tickets" "centreon-web") COMPONENTS_MODULES=("centreon-anomaly-detection" "centreon-autodiscovery" "centreon-bam" "centreon-cloud-business-extensions" "centreon-cloud-extensions" "centreon-it-edition-extensions" "centreon-license-manager" "centreon-map" "centreon-mbi" "centreon-pp-manager") COMPONENTS_COLLECT=("centreon-collect") diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7fcd32142f9..3ae7646b06a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,4 +50,3 @@ jobs: jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} jira_webhook_url: ${{ secrets.JIRA_RELEASE_WEBHOOK }} - module_name: ${{ env.module }} From f9ae4f58eea7fd7e0cce726ae5c1cd71630559d2 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:15:57 +0100 Subject: [PATCH 4/5] Update .github/workflows/release.yml Co-authored-by: Kevin Duret --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ae7646b06a..3a02068db91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: if [[ "${{ github.base_ref }}" == 'master' || "${{ github.base_ref }}" =~ ^[2-9][0-9].[0-9][0-9].x ]];then echo "[DEBUG] base_ref is valid: ${{ github.base_ref }}" else - echo "[DEBUG] base_ref is not valid (${{ github.base_ref }}), exiting." + echo "::error::base_ref is not valid (${{ github.base_ref }}), exiting." exit 1 fi shell: bash From 5988feda0dadd9a0eb3c39c3b470e66b4e3513be Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:42:58 +0100 Subject: [PATCH 5/5] Remove unused arrays --- .github/actions/release/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml index 43b85fb70bb..ad9f980d751 100644 --- a/.github/actions/release/action.yml +++ b/.github/actions/release/action.yml @@ -27,8 +27,7 @@ runs: run: | set -eu - COMPONENTS_OSS=("centreon-awie" "centreon-dsm" "centreon-gorgone" "centreon-ha" "centreon-open-tickets" "centreon-web") - COMPONENTS_MODULES=("centreon-anomaly-detection" "centreon-autodiscovery" "centreon-bam" "centreon-cloud-business-extensions" "centreon-cloud-extensions" "centreon-it-edition-extensions" "centreon-license-manager" "centreon-map" "centreon-mbi" "centreon-pp-manager") + # Variables COMPONENTS_COLLECT=("centreon-collect") CURRENT_STABLE_BRANCH_MAJOR_VERSION="" declare -a NEW_STABLE_TAGS=()