generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (87 loc) · 3.26 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#
# This source file is part of the Stanford Spezi open-source project
#
# SPDX-FileCopyrightText: 2024 Stanford University
#
# SPDX-License-Identifier: MIT
#
name: Release
on:
release:
types: [published]
push:
branches:
- fixReleaseNotes
concurrency:
group: production
cancel-in-progress: false
jobs:
formatreleasenotes:
name: Format Release Notes
runs-on: ubuntu-latest
outputs:
releasenotes: ${{ steps.releasenotes.outputs.releasenotes }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Dependencies
run: pip install requests
- name: Fetch and Process releasenotes
id: releasenotes
run: |
python <<EOF
import re
import os
import requests
# Fetch release notes from the GitHub API
RELEASE_TAG = "2.0.1"
REPO = "StanfordBDHG/ENGAGE-HF-iOS"
URL = f"https://api.github.com/repos/{REPO}/releases/tags/{RELEASE_TAG}"
response = requests.get(URL)
release = response.json()
releasenotes = release.get('body', '')
# Extract the "What's Changed" section
match = re.search(r"(## What's Changed.*?)(\n##|$)", releasenotes, flags=re.DOTALL)
if match:
releasenotes = match.group(1)
else:
releasenotes = "Bug fixes and performance improvements."
# Remove bold (**text**), italics (*text* or _text_), and underline (__text__)
releasenotes = re.sub(r'\*\*(.*?)\*\*', r'\1', releasenotes) # Remove **bold**
releasenotes = re.sub(r'\*(.*?)\*', r'\1', releasenotes) # Remove *italics*
releasenotes = re.sub(r'_(.*?)_', r'\1', releasenotes) # Remove _italics/underline_
releasenotes = re.sub(r'__(.*?)__', r'\1', releasenotes) # Remove __underline__
# Remove all headers (e.g., ## What's Changed)
releasenotes = re.sub(r'^#+\s*', '', releasenotes, flags=re.MULTILINE)
# Remove inline links but keep text (e.g., [text](url) → text)
releasenotes = re.sub(r'\[(.*?)\]\((.*?)\)', r'\1', releasenotes)
# Shorten pull request URLs to reference IDs (e.g., #123)
releasenotes = re.sub(r'https://github\.com/[^/]+/[^/]+/pull/(\d+)', r'#\1', releasenotes)
# Replace list items "*" with "-"
releasenotes = re.sub(r'^\s*\*\s+', '- ', releasenotes, flags=re.MULTILINE)
# Remove excess blank lines
releasenotes = re.sub(r'\n\s*\n', '\n', releasenotes).strip()
# Write cleaned releasenotes to GITHUB_OUTPUT
with open(os.environ['GITHUB_OUTPUT'], 'a') as output_file:
output_file.write(f"releasenotes<<{releasenotes}\n")
EOF
- name: Formatted Release Notes
run: |
echo "Formatted Release Notes:"
echo "${{ steps.releasenotes.outputs.releasenotes }}"
build-and-test:
name: Build and Test
uses: ./.github/workflows/deployment.yml
needs: formatreleasenotes
permissions:
contents: read
checks: write
actions: read
security-events: write
secrets: inherit
with:
environment: production
version: ${{ github.event.release.tag_name }}
releasenotes: ${{ needs.formatreleasenotes.outputs.releasenotes }}