From e5d8a7b2fdf86c95a91282043c131f5e35a09c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C3=B3=C5=BAwicki?= Date: Wed, 27 Sep 2023 09:58:09 +0200 Subject: [PATCH 1/2] Workflow to automate creating JIRA releases --- .github/workflows/release-jira.yaml | 79 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 15 ++++-- 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release-jira.yaml diff --git a/.github/workflows/release-jira.yaml b/.github/workflows/release-jira.yaml new file mode 100644 index 00000000..c03bbb00 --- /dev/null +++ b/.github/workflows/release-jira.yaml @@ -0,0 +1,79 @@ +# Copyright (C) 2023 Dynamic Solutions +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Create JIRA release + +on: + workflow_dispatch: + inputs: + tag: + description: "Tag" + type: string + required: false + workflow_call: + inputs: + tag: + description: "Tag" + type: string + required: false + +jobs: + create-jira-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: '0' + - name: Prepare release + run: | + PROJECT_NAME="WOS" + RELEASE_NAME_PREFIX="howlite-" + + if [ -z "${{ inputs.tag }}" ]; then + RELEASED_VERSION=$(git describe --tags --abbrev=0) + else + RELEASED_VERSION=${{ inputs.tag }} + fi + + echo "Released version: ${RELEASED_VERSION}" + + PREVIOUS_VERSION=$(git describe --abbrev=0 ${RELEASED_VERSION}^) + echo "Previous version: ${RELEASED_VERSION}" + + COMMITS=$(git log ${RELEASED_VERSION}..${RELEASED_VERSION} --pretty=format:"%s" | grep ${PROJECT_NAME}) + TICKETS=$(echo "${COMMITS}" | grep -o ${PROJECT_NAME}'\-[0-9]\+' | sort -u | paste -sd "," -) + echo "Tickets found in commit messages: ${TICKETS}" + + echo "RELEASE_NAME=${RELEASE_NAME_PREFIX}${RELEASED_VERSION}" >> $GITHUB_ENV + echo "TICKETS=${TICKETS}" >> $GITHUB_ENV + + if [ -z "${TICKETS}" ]; then + echo "HAS_TICKETS=false" >> $GITHUB_ENV + echo "No tickets found. JIRA release won't be created." + else + echo "HAS_TICKETS=true" >> $GITHUB_ENV + fi + + - name: Create release + if: ${{ env.HAS_TICKETS == 'true' }} + uses: armona/jira-release-actions@v2.0.6 + with: + create: true + email: ${{ secrets.ATLASSIAN_CLOUD_USER }} + api_token: ${{ secrets.ATLASSIAN_CLOUD_APIKEY }} + subdomain: ${{ secrets.ATLASSIAN_CLOUD_DOMAIN }} + jira_project: 10201 + tickets: ${{ env.TICKETS }} + release_name: ${{ env.RELEASE_NAME }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index baa40e9e..fd8f6c8f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,9 +25,10 @@ permissions: contents: read jobs: - build-and-test-latest-websight: + release: runs-on: ubuntu-latest - + outputs: + released-version: ${{ steps.prepare-release.outputs.RELEASED_VERSION }} steps: - uses: actions/checkout@v3 with: @@ -55,6 +56,7 @@ jobs: export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain websight --domain-owner ${{ secrets.AWS_ACCOUNT_ID }} --query authorizationToken --output text` echo "CODEARTIFACT_AUTH_TOKEN=${CODEARTIFACT_AUTH_TOKEN}" >> $GITHUB_ENV - name: Prepare release + id: prepare-release env: AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} run: | @@ -68,6 +70,7 @@ jobs: ./mvnw --batch-mode -s ~/.m2/settings-websight-public.xml release:prepare RELEASED_VERSION=$(git describe --tags --abbrev=0) echo "RELEASED_VERSION=${RELEASED_VERSION}" >> $GITHUB_ENV + echo "RELEASED_VERSION=${RELEASED_VERSION}" >> $GITHUB_OUTPUTS - name: Release to Code Artifact env: AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} @@ -79,4 +82,10 @@ jobs: run: | curl -s https://ws-dev-public.s3.eu-central-1.amazonaws.com/settings-s3-publication.xml --output ~/.m2/settings-s3-publication.xml git checkout tags/${RELEASED_VERSION} - ./mvnw --batch-mode -s ~/.m2/settings-s3-publication.xml -P s3-distribution -Dmaven.install.skip=true -DskipTests=true deploy \ No newline at end of file + ./mvnw --batch-mode -s ~/.m2/settings-s3-publication.xml -P s3-distribution -Dmaven.install.skip=true -DskipTests=true deploy + release-jira: + needs: release + uses: ./.github/workflows/release-jira.yaml + secrets: inherit + with: + tag: ${{ needs.release.outputs.released-version }} \ No newline at end of file From e7a96abfaa820a0bb07ac8c287090605d71bf86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C3=B3=C5=BAwicki?= Date: Wed, 27 Sep 2023 10:22:01 +0200 Subject: [PATCH 2/2] Workflow to automate creating JIRA releases --- .github/workflows/release-jira.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-jira.yaml b/.github/workflows/release-jira.yaml index c03bbb00..9cc22bbf 100644 --- a/.github/workflows/release-jira.yaml +++ b/.github/workflows/release-jira.yaml @@ -50,9 +50,9 @@ jobs: echo "Released version: ${RELEASED_VERSION}" PREVIOUS_VERSION=$(git describe --abbrev=0 ${RELEASED_VERSION}^) - echo "Previous version: ${RELEASED_VERSION}" + echo "Previous version: ${PREVIOUS_VERSION}" - COMMITS=$(git log ${RELEASED_VERSION}..${RELEASED_VERSION} --pretty=format:"%s" | grep ${PROJECT_NAME}) + COMMITS=$(git log ${PREVIOUS_VERSION}..${RELEASED_VERSION} --pretty=format:"%s" | grep ${PROJECT_NAME}) TICKETS=$(echo "${COMMITS}" | grep -o ${PROJECT_NAME}'\-[0-9]\+' | sort -u | paste -sd "," -) echo "Tickets found in commit messages: ${TICKETS}"