Skip to content

Commit

Permalink
chore: create jira release
Browse files Browse the repository at this point in the history
  • Loading branch information
markusrf authored and jsolaas committed May 3, 2024
1 parent 0bf6fe6 commit f5c8e55
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/create-jira-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Create Jira release

on:
workflow_call:
secrets:
JIRA_RELEASE_WEBHOOK:
required: true
inputs:
tag:
required: true
type: string
workflow_dispatch:
inputs:
tag:
required: true
type: string

jobs:
create-jira-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Collect and report issues to jira
run: |
./scripts/create-jira-release.sh ${{ inputs.tag }} ${{ secrets.JIRA_RELEASE_WEBHOOK }}
12 changes: 12 additions & 0 deletions .github/workflows/on-tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
push:
tags:
- 'v*.*.*'

jobs:
create-jira-release:
secrets:
jira_release_webhook: ${{ secrets.JIRA_RELEASE_WEBHOOK }}
uses: equinor/ecalc/.github/workflows/create-jira-release.yml@main
with:
tag: ${GITHUB_REF#refs/tags/}
33 changes: 33 additions & 0 deletions scripts/create-jira-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -eou pipefail

release_version=$1
webhook_url=$2

# Create array of sorted tags
mapfile -t tags < <(git tag | sort -Vr)

echo "Found tags:"
echo "${#tags[@]}"

# Loop array to find previous tag
for ((i=0; i < "${#tags[@]}"; i++)); do
if [[ "$release_version" = "${tags[$i]}" ]]; then
previous_tag="${tags[($i + 1)]}"
break
fi
done

echo "Found previous release $previous_tag"

mapfile -t issues < <(git log "$previous_tag".."$release_version" | grep -oP 'ECALC-\d+')
issues_json=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${issues[@]}")

# Create webhook body
body=$(jq --arg libecalcVersion "$release_version" --argjson issues_json "$issues_json" -Rn '{"issues": $issues_json|unique, "libecalcVersion": $libecalcVersion}')

echo "$body"

# Trigger webhook
curl -X POST -H 'Content-type: application/json' --silent --output /dev/null --data "$body" "$webhook_url"

0 comments on commit f5c8e55

Please sign in to comment.