This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
2 changed files
with
38 additions
and
34 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 |
---|---|---|
|
@@ -21,41 +21,24 @@ jobs: | |
get-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.vars.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get Latest Release | ||
id: get_latest_release | ||
uses: cardinalby/git-get-release-action@v1 | ||
with: | ||
latest: true | ||
prerelease: true | ||
# excludes: rc, alpha, beta # Optional. Exclude keywords like rc, alpha, beta releases. | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
version: ${{ steps.set_version.outputs.version }} | ||
|
||
- name: Bump possible release candidate version | ||
id: bump_version | ||
uses: christian-draeger/[email protected] | ||
with: | ||
current-version: ${{ steps.get_latest_release.outputs.name }} | ||
version-fragment: "rc" | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
- name: Check out the branch or tag | ||
id: vars | ||
run: | | ||
# echo "version=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | ||
if [[ $GITHUB_REF =~ ^refs/tags/ ]]; then | ||
VERSION=${{ github.ref_name }} | ||
elif [[ $GITHUB_REF =~ ^refs/heads/release/.* ]]; then | ||
VERSION=${{ steps.bump_version.outputs.next-version }} | ||
else | ||
VERSION=0.0.1 | ||
fi | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set Version | ||
id: set_version | ||
run: | | ||
if [[ $GITHUB_REF =~ ^refs/tags/ ]]; then | ||
VERSION=${{ github.ref_name }} | ||
elif [[ $GITHUB_REF =~ ^refs/heads/release/.* ]]; then | ||
chmod +x ./scripts/generate-rc-version.sh | ||
VERSION=$(echo ./scripts/generate-rc-version.sh ${{ github.ref }}) | ||
else | ||
VERSION=0.0.1 | ||
fi | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
build-binaries: | ||
name: Build ${{ matrix.config.os }} @ ${{ matrix.config.arch }} | ||
|
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,21 @@ | ||
#!/bin/bash | ||
|
||
BRANCH_NAME=$1 | ||
|
||
# Extract version number from the branch name | ||
VERSION=$(echo $BRANCH_NAME | grep -oP 'release\/\K\d+\.\d+\.\d+') | ||
|
||
# Check if there are any releases matching the branch's version pattern | ||
RELEASES=$(git tag --list "$VERSION-rc*" | sort -V) | ||
|
||
if [ -z "$RELEASES" ]; then | ||
# If no releases are found, set the version to <branch_version>-rc0 | ||
VERSION="$VERSION-rc0" | ||
else | ||
# If there are releases, find the latest release and increment the version | ||
LATEST_RELEASE=$(echo "$RELEASES" | tail -n 1) | ||
NEXT_RC_NUMBER=$(echo "$LATEST_RELEASE" | grep -oP '\d+$' | awk '{print $1 + 1}') | ||
VERSION="$VERSION-rc$NEXT_RC_NUMBER" | ||
fi | ||
|
||
echo $VERSION |