-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #600 from arabcoders/dev
more github workflow updates
- Loading branch information
Showing
4 changed files
with
137 additions
and
110 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Create new release. | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create_release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Determine current branch | ||
id: branch | ||
run: | | ||
# github.ref_name should be "master", "main", or your branch name | ||
echo "BRANCH_NAME=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT | ||
- name: Fetch the two latest tags for this branch | ||
id: last_two_tags | ||
run: | | ||
git fetch --tags | ||
BRANCH_NAME="${{ steps.branch.outputs.BRANCH_NAME }}" | ||
echo "Current branch: $BRANCH_NAME" | ||
# List tags matching "branchname-*" and sort by *creation date* descending | ||
# Then pick the top 2 | ||
LATEST_TAGS=$(git tag --list "${BRANCH_NAME}-*" --sort=-creatordate | head -n 2) | ||
TAG_COUNT=$(echo "$LATEST_TAGS" | wc -l) | ||
echo "Found tags:" | ||
echo "$LATEST_TAGS" | ||
if [ "$TAG_COUNT" -lt 2 ]; then | ||
echo "Not enough tags found (need at least 2) to compare commits." | ||
echo "NOT_ENOUGH_TAGS=true" >> "$GITHUB_OUTPUT" | ||
exit 0 | ||
fi | ||
# The first line is the newest tag | ||
TAG_NEWEST=$(echo "$LATEST_TAGS" | sed -n '1p') | ||
# The second line is the previous newest | ||
TAG_PREVIOUS=$(echo "$LATEST_TAGS" | sed -n '2p') | ||
echo "Newest tag: $TAG_NEWEST" | ||
echo "Previous tag: $TAG_PREVIOUS" | ||
# Expose them as outputs for next step | ||
echo "NOT_ENOUGH_TAGS=false" >> "$GITHUB_OUTPUT" | ||
echo "TAG_NEWEST=$TAG_NEWEST" >> "$GITHUB_OUTPUT" | ||
echo "TAG_PREVIOUS=$TAG_PREVIOUS" >> "$GITHUB_OUTPUT" | ||
- name: Generate commit log for newest tag | ||
id: commits | ||
if: steps.last_two_tags.outputs.NOT_ENOUGH_TAGS != 'true' | ||
run: | | ||
TAG_NEWEST="${{ steps.last_two_tags.outputs.TAG_NEWEST }}" | ||
TAG_PREVIOUS="${{ steps.last_two_tags.outputs.TAG_PREVIOUS }}" | ||
echo "Comparing commits between: $TAG_PREVIOUS..$TAG_NEWEST" | ||
LOG=$(git log "$TAG_PREVIOUS".."$TAG_NEWEST" --pretty=format:"- %h %s by %an") | ||
echo "LOG<<EOF" >> "$GITHUB_ENV" | ||
echo "$LOG" >> "$GITHUB_ENV" | ||
echo "EOF" >> "$GITHUB_ENV" | ||
- name: Create / Update GitHub Release for the newest tag | ||
if: steps.last_two_tags.outputs.NOT_ENOUGH_TAGS != 'true' | ||
uses: softprops/action-gh-release@master | ||
with: | ||
tag_name: ${{ steps.last_two_tags.outputs.TAG_NEWEST }} | ||
name: "${{ steps.last_two_tags.outputs.TAG_NEWEST }}" | ||
body: ${{ env.LOG }} | ||
append_body: true | ||
generate_release_notes: true | ||
make_latest: true | ||
draft: false | ||
prerelease: false | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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 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 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