Skip to content

Commit

Permalink
fix: clean release tags and release notes (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
osama-salman99 authored Feb 11, 2024
1 parent 09664a6 commit f746261
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 17 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/generator-draft-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Clean release tags
run: ./clean-release-tags.sh
- name: Get latest tag
run: |
latest_tag=$(git show-ref -s "$(./get-latest-tag.sh)")
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Create tag
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GH_PAT }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v1.0.0',
sha: '${{ env.LATEST_TAG}}'
})
- name: Setup Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -17,3 +36,6 @@ jobs:
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean release tags
if: always()
run: ./clean-release-tags.sh
1 change: 1 addition & 0 deletions .github/workflows/generator-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ jobs:
draft_release:
if: ${{ github.event.inputs.production_release == 'true' }}
needs: [ generate_sdk ]
secrets: inherit
uses: ./.github/workflows/generator-draft-release.yaml
12 changes: 2 additions & 10 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
[
"@semantic-release/release-notes-generator",
{
"linkCompare": false,
"preset": "conventionalcommits",
"parserOpts": {
"noteKeywords": [
Expand All @@ -61,19 +62,10 @@
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/github",
{
"successComment": false,
"failComment": false,
"failTitle": false,
"draftRelease": true
}
],
[
"@semantic-release/exec",
{
"successCmd": "./update-github-release.sh v${nextRelease.version}"
"successCmd": "./create-github-release.sh '${nextRelease.notes}'"
}
]
]
Expand Down
10 changes: 10 additions & 0 deletions clean-release-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

tags=("v1.0.0" "v1.0.1" "v1.1.0" "v2.0.0")

for tag in "${tags[@]}"; do
if [ $(git tag -l "$tag") ]; then
git push origin --delete "$tag"
echo "Deleted $tag"
fi
done
14 changes: 14 additions & 0 deletions create-github-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

release_notes=$1
echo "$release_notes" &> release-notes.txt
sed -i '1d' release-notes.txt

previous_tag=$(./get-latest-tag.sh)
today="v$(date "+%Y%m%d")"

echo "today: $today"

git tag "$today"
git push --tags
gh release create "$today" --draft --generate-notes --latest --notes-file release-notes.txt --notes-start-tag "$previous_tag" --title "$today"
7 changes: 7 additions & 0 deletions get-latest-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

git fetch --tags
tags=$(git tag -l "v*")
latest_tag=$(echo "$tags" | grep -E '^v[0-9]+$' | sort -Vr | head -n 1)

echo "$latest_tag"
7 changes: 0 additions & 7 deletions update-github-release.sh

This file was deleted.

0 comments on commit f746261

Please sign in to comment.