-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5c0ca3
commit 66a9eea
Showing
10 changed files
with
110 additions
and
53 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
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,65 @@ | ||
name: Build Number | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
build-number: | ||
description: "The build number generated from git tags on current SHA." | ||
value: ${{ jobs.build.outputs.build-number }} | ||
type: integer | ||
inputs: | ||
token: | ||
description: 'GitHub token or PAT token' | ||
required: false | ||
default: ${{ github.token }} | ||
type: string | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
build_number: ${{ steps.build-number.outputs.build_number }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Generate build number | ||
id: build-number | ||
env: | ||
INPUT_GITHUB_TOKEN: ${{ inputs.token }} | ||
run: | | ||
CURRENT_BUILD_NUMBER=$(git show-ref --tags | grep "$GITHUB_SHA" | sort -nr | head -1 | grep -oE "build-number--(\d+)" | grep -oE "\d+") | ||
echo "Found build number $CURRENT_BUILD_NUMBER for current SHA." | ||
if [ -z "${CURRENT_BUILD_NUMBER}" ]; then | ||
echo "No build number found for current SHA" | ||
# Get the latest build number | ||
LATEST_BUILD_NUMBER=$(git show-ref --tags | grep -oE "build-number-(\d+)" | sort -nr | head -1 | grep -oE "\d+") | ||
if [ -z "${LATEST_BUILD_NUMBER}" ]; then | ||
echo "No build number found in tags. Please create a tag with the format 'build-number-1' on main branch." | ||
exit 1 | ||
fi | ||
CURRENT_BUILD_NUMBER="$((LATEST_BUILD_NUMBER + 1))" | ||
git tag "build-number-$CURRENT_BUILD_NUMBER" | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
GITHUB_URL_PROTOCOL=$(echo "${GITHUB_SERVER_URL%?(:)//*}" | ||
REMOTE_REPO="${GITHUB_URL_PROTOCOL}//oauth2:${INPUT_GITHUB_TOKEN}@${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" | ||
PUSH_PARAMETERS="${REMOTE_REPO}" | ||
echo "Pushing build number tag build-number-$CURRENT_BUILD_NUMBER to Github ($GITHUB_REF)." | ||
git push "$PUSH_PARAMETERS" --tags | ||
else | ||
echo "Skipping tag creation." | ||
exit 0 | ||
fi | ||
echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" > "$GITHUB_ENV" |
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
This file was deleted.
Oops, something went wrong.
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
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