Update #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 only the "What's Changed" section | |
match = re.search(r"## What's Changed(.*?)(##|$)", releasenotes, flags=re.DOTALL) | |
if match: | |
releasenotes = match.group(1).strip() | |
else: | |
releasenotes = "Bug fixes and performance improvements." | |
# Remove all Markdown formatting | |
releasenotes = re.sub(r'^#+\s*', '', releasenotes, flags=re.MULTILINE) # Remove headers | |
releasenotes = re.sub(r'\*\*|__|\*|_', '', releasenotes) # Remove bold, italics, etc. | |
releasenotes = re.sub(r'\[(.*?)\]\((.*?)\)', r'\1', releasenotes) # Remove links but keep text | |
releasenotes = re.sub(r'https://github\.com/[^/]+/[^/]+/pull/(\d+)', r'#\1', releasenotes) # Shorten pull request URLs | |
# 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<<EOF\n{releasenotes}\nEOF\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 }} |