Skip to content

Commit

Permalink
replaces manual generation of release notes with api call
Browse files Browse the repository at this point in the history
  • Loading branch information
dvviktordelev committed Oct 21, 2024
1 parent dd3d298 commit 2f7ff83
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-node-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ env:
PYPI_REGISTRY: "https://upload.pypi.org/legacy/"
PYPI_USERNAME: "datavisyn"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"
POSTGRES_HOSTNAME: postgres_${{ github.job }}_${{ inputs.deduplication_id }}_${{ github.run_id }}_${{ github.run_attempt }}

permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ on:
env:
NPM_REGISTRY: "https://registry.npmjs.org/"
NODE_VERSION: "20.9"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
TIME_ZONE: "Europe/Vienna"
NODE_VERSION: "20.9"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"
PYTHON_BASE_IMAGE: "python:3.10.8-slim-bullseye"
DATAVISYN_PYTHON_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/python:main"
DATAVISYN_NGINX_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/nginx:main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ permissions:
contents: read

env:
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-push-helm-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:
contents: read

env:
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

concurrency:
group: '${{ github.workflow }}-${{ github.ref || github.head_ref }}'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
PYPI_REGISTRY: "https://upload.pypi.org/legacy/"
PYPI_USERNAME: "test"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-single-product-part.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ env:
TIME_ZONE: "Europe/Vienna"
NODE_VERSION: "20.9"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"
PYTHON_BASE_IMAGE: "python:3.10.8-slim-bullseye"
DATAVISYN_PYTHON_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/python:main"
DATAVISYN_NGINX_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/nginx:main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-workspace-product-part.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ env:
TIME_ZONE: "Europe/Vienna"
NODE_VERSION: "20.9"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"
PYTHON_BASE_IMAGE: "python:3.10.8-slim-bullseye"
DATAVISYN_PYTHON_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/python:main"
DATAVISYN_NGINX_BASE_IMAGE: "188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/nginx:main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-helm-chart-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ permissions:
contents: read

env:
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

jobs:
check-helm-chart-version:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ concurrency:

env:
GA_VERSION: "main"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-node-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
PYPI_REGISTRY: "https://upload.pypi.org/legacy/"
PYPI_USERNAME: "datavisyn"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
env:
NPM_REGISTRY: "https://registry.npmjs.org/"
NODE_VERSION: "20.9"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
env:
PYPI_REGISTRY: "https://upload.pypi.org/legacy/"
PYTHON_VERSION: "3.10"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
env:
GA_VERSION: "main"
GITHUB_USER: "datavisyn-bot"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"

jobs:
###############################################################################################################
Expand Down
46 changes: 17 additions & 29 deletions .github/workflows/release-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ concurrency:
env:
GA_VERSION: "main"
GITHUB_USER: "datavisyn-bot"
WORKFLOW_BRANCH: "main"
WORKFLOW_BRANCH: "vdelev_auto_releasenotes"
GITHUB_TOKEN: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }}
CHARTMUSEUM_USER: ${{ secrets.DV_CHARTMUSEUM_USER }}
CHARTMUSEUM_PASSWORD: ${{ secrets.DV_CHARTMUSEUM_PASSWORD }}
Expand Down Expand Up @@ -223,38 +223,27 @@ jobs:
- name: push all changes
run: |
git push origin release-"$RELEASE_VERSION"
- name: get latest release date
id: get-release-date
run: |
LATEST_RELEASE=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/latest")
LATEST_RELEASE_DATE=$(echo "$LATEST_RELEASE" | jq -r '.published_at')
echo "RELEASE_DATE=$LATEST_RELEASE_DATE" >> "$GITHUB_ENV"
- name: fetch merged PRs since last release
id: fetch-prs
# New Step: Generate Release Notes using GitHub API
- name: Generate release notes
id: generate-release-notes
run: |
PRS=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls?state=closed&base=${{ github.ref_name }}&sort=updated&direction=desc")
response=$(curl -s -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/generate-notes \
-d "$(jq -n --arg tag_name "${{ env.RELEASE_VERSION }}" \
--arg target_commitish "${{ github.ref_name }}" \
'{tag_name: $tag_name, target_commitish: $target_commitish}')")
RELEASE_NOTES=$(echo "$response" | jq -r '.body')
if echo "$PRS" | jq -e . > /dev/null 2>&1; then
PR_NOTES=$(echo "$PRS" | jq -r --arg since "$RELEASE_DATE" '.[] | select(.merged_at != null and .merged_at > $since) | "* \(.title) ([#\(.number)](\(.html_url)))"')
else
PR_NOTES="could not fetch release notes"
fi
echo "$PR_NOTES" > pr_notes.txt
echo "$RELEASE_NOTES" > release_notes.txt
- name: create pr
id: create-pr
run: |
PR_NOTES=$(cat pr_notes.txt)
PR_NOTES=$(printf "## What's changed\n\n%s" "$PR_NOTES")
# Create a pull request with release notes
PR_NOTES=$(cat release_notes.txt)
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
Expand All @@ -266,5 +255,4 @@ jobs:
--arg body "$PR_NOTES" \
--arg head "release-${{ env.RELEASE_VERSION }}" \
--arg base "${{ inputs.base_branch }}" \
--argjson draft false \
'{title: $title, body: $body, head: $head, base: $base, draft: $draft}')"
'{title: $title, body: $body, head: $head, base: $base}')"

0 comments on commit 2f7ff83

Please sign in to comment.