-
Notifications
You must be signed in to change notification settings - Fork 10
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
125 additions
and
131 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 |
---|---|---|
@@ -1,82 +1,82 @@ | ||
name: Version Release | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: [develop] | ||
|
||
name: Version Release | ||
|
||
on: | ||
schedule: | ||
- cron: '0 4 * * *' # Runs at 04:00 UTC every day | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
bump-semver: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Ensure full history for diff comparisons | ||
|
||
- name: Run bump semver script | ||
run: | | ||
chmod +x ./.github/bump_version.sh | ||
./.github/bump_version.sh "${{ github.event.pull_request.title }}" | ||
- name: Commit version bump | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
git add VERSION | ||
git diff-index --quiet HEAD || git commit -m "Bump version to $(cat VERSION) [skip ci]" | ||
git push origin HEAD:develop --follow-tags | ||
evaluate-release: | ||
if: github.event.pull_request.merged == true | ||
bump-semver: | ||
runs-on: ubuntu-latest | ||
needs: bump-semver | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
fetch-depth: 0 # Get full history for tag comparison | ||
|
||
- name: Read raw version | ||
id: version | ||
run: | | ||
VERSION=$(cat VERSION) | ||
echo "raw_version=${VERSION}" >> $GITHUB_OUTPUT | ||
- name: Get previous tag | ||
id: previous-tag | ||
run: | | ||
git fetch --tags | ||
# Default to v0.0.0 if no tags exist | ||
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | ||
echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT | ||
echo "prev_version=${PREV_TAG#v}" >> $GITHUB_OUTPUT | ||
- name: Compare versions | ||
id: version-check | ||
run: | | ||
NEW_VERSION=${{ steps.version.outputs.raw_version }} | ||
PREV_VERSION=${{ steps.previous-tag.outputs.prev_version }} | ||
IFS='.' read -ra NEW <<< "$NEW_VERSION" | ||
IFS='.' read -ra PREV <<< "$PREV_VERSION" | ||
# Major/minor check (ignore patch) | ||
if [[ ${NEW[0]} -gt ${PREV[0]} || (${NEW[0]} -eq ${PREV[0]} && ${NEW[1]} -gt ${PREV[1]}) ]]; | ||
then | ||
echo "RELEASE_NEEDED=true" >> $GITHUB_ENV | ||
echo "new_tag=v${NEW_VERSION}" >> $GITHUB_ENV | ||
fi | ||
- name: Create semver tag and release | ||
if: env.RELEASE_NEEDED == 'true' | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ env.new_tag }} | ||
release_name: ${{ env.new_tag }} | ||
draft: false | ||
prerelease: false | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ref: develop | ||
fetch-depth: 0 # Ensure full history for diff comparisons | ||
|
||
- name: Run bump semver script | ||
run: | | ||
chmod +x ./.github/bump_version.sh | ||
./.github/bump_version.sh | ||
- name: Commit version bump | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
git add VERSION | ||
git diff-index --quiet HEAD || git commit -m "Bump version to $(cat VERSION) [skip ci]" | ||
git push origin HEAD:develop --follow-tags | ||
evaluate-release: | ||
runs-on: ubuntu-latest | ||
needs: bump-semver | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
fetch-depth: 0 # Get full history for tag comparison | ||
|
||
- name: Read raw version | ||
id: version | ||
run: | | ||
VERSION=$(cat VERSION) | ||
echo "raw_version=${VERSION}" >> $GITHUB_OUTPUT | ||
- name: Get previous tag | ||
id: previous-tag | ||
run: | | ||
git fetch --tags | ||
# Default to v0.0.0 if no tags exist | ||
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | ||
echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT | ||
echo "prev_version=${PREV_TAG#v}" >> $GITHUB_OUTPUT | ||
- name: Compare versions | ||
id: version-check | ||
run: | | ||
NEW_VERSION=${{ steps.version.outputs.raw_version }} | ||
PREV_VERSION=${{ steps.previous-tag.outputs.prev_version }} | ||
IFS='.' read -ra NEW <<< "$NEW_VERSION" | ||
IFS='.' read -ra PREV <<< "$PREV_VERSION" | ||
# Major/minor check (ignore patch) | ||
if [[ ${NEW[0]} -gt ${PREV[0]} || (${NEW[0]} -eq ${PREV[0]} && ${NEW[1]} -gt ${PREV[1]}) ]]; | ||
then | ||
echo "RELEASE_NEEDED=true" >> $GITHUB_ENV | ||
echo "new_tag=v${NEW_VERSION}" >> $GITHUB_ENV | ||
fi | ||
- name: Create semver tag and release | ||
if: env.RELEASE_NEEDED == 'true' | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ env.new_tag }} | ||
release_name: ${{ env.new_tag }} | ||
draft: false | ||
prerelease: false | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |