Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zenodo badge in the release summary notes #2838

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,53 @@ jobs:
python .ci-helpers/get_next_version.py
echo "NEW_TAG=$(python .ci-helpers/get_next_version.py)" >> $GITHUB_ENV

- name: Initialize release
uses: softprops/action-gh-release@v1
with:
name: TARDIS v${{ env.NEW_TAG }}
tag_name: release-${{ env.NEW_TAG }}
body: "This release has been created automatically by the TARDIS continuous delivery pipeline."
draft: false

- name: Wait for Zenodo to update the latest release
run: sleep 120

- name: Fetch Latest DOI from Zenodo
id: fetch-doi
run: |
CONCEPT_DOI="592480"
# Make the API request for BibTeX format, following redirects
response=$(curl -s -L -H "Accept: application/x-bibtex" "https://zenodo.org/api/records/${CONCEPT_DOI}")

# Extract the full DOI value correctly
doi=$(echo "$response" | grep -oP 'doi\s*=\s*{([^}]+)}' | grep -oP '\{([^}]+)\}' | sed 's/[{}]//g')

# Extract the DOI URL directly from the response
url=$(echo "$response" | grep -oP 'url\s*=\s*{([^}]+)}' | grep -oP '\{([^}]+)\}' | sed 's/[{}]//g')

echo "Extracted DOI: ${doi}"
echo "Extracted URL: ${url}"
# Create DOI badge using the full DOI value
doi_badge="[![DOI Badge](https://img.shields.io/badge/DOI-${doi}-blue)](${url})"

# Store results in GitHub environment variables
echo "doi_badge=${doi_badge}" >> $GITHUB_ENV
echo "doi_url=${url}" >> $GITHUB_ENV

- name: Generate and process changelog
run: |
CHANGELOG=$(git cliff --config pyproject.toml --unreleased | sed -n '/^## Changelog/,$p' | grep -vE '^(ERROR|WARN)')
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Create new release
- name: Update release with changelog and DOI
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.BOT_TOKEN }}
name: TARDIS v${{ env.NEW_TAG}}
tag_name: release-${{ env.NEW_TAG }}
prerelease: false
body: |
This release has been created automatically by the TARDIS continuous delivery pipeline.

${{ env.doi_badge }}
${{ env.CHANGELOG }}

A complete list of changes for this release is available at [CHANGELOG.md](https://github.com/tardis-sn/tardis/blob/master/CHANGELOG.md).
Expand All @@ -64,3 +94,4 @@ jobs:
conda-osx-64.lock
conda-lock.yml
fail_on_unmatched_files: false
draft: false
Loading