-
Notifications
You must be signed in to change notification settings - Fork 98
Chore: automate init version #573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Piloalucard
wants to merge
28
commits into
LinearTapeFileSystem:main
Choose a base branch
from
Piloalucard:chore/automatize-init-version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
33dc907
Create bump-version-from-tag.yml
Piloalucard a412fc7
Revert "Create bump-version-from-tag.yml"
Piloalucard 5dd7a6d
Create update-version.yml
Piloalucard 91cd0b2
Update update-version.yml
Piloalucard c9ae68c
Update version to 2.4.8.2 from upstream tag v2.4.8.2-10520
github-actions[bot] 6547b62
Change name and commit test
Piloalucard a4d78c1
Merge branch 'chore/automatize-init-version' of https://github.com/Pi…
Piloalucard 3bf8ad7
Revert "Update version to 2.4.8.2 from upstream tag v2.4.8.2-10520"
Piloalucard dd35678
Update update-version.yml
Piloalucard 69fb111
Update update-version.yml
Piloalucard 3bf638e
Update version to 2.4.8.2 from upstream tag v2.4.8.2-10520
github-actions[bot] 07989bc
Updated name
Piloalucard f6d300a
Extract build num too
Piloalucard ada5cc2
chore: sync configure.ac version to 2.4.8.2 (10520) (upstream: v2.4.8…
github-actions[bot] ab19f88
Update update-version.yml
Piloalucard 3b577f4
Update configure.ac
Piloalucard f8b23b3
chore: sync configure.ac version to 2.4.8.2 (10520) (upstream: v2.4.8…
github-actions[bot] fb5d158
New apporach
Piloalucard 46a1405
Update version-bump-prelim.yml
Piloalucard 6862bd9
Re-doing
Piloalucard fde1a5a
chore: update version to 2.4.8.3 (Prelim)
github-actions[bot] b28ecec
Delete version-bump-prelim.yml
Piloalucard e7c2043
Merge branch 'chore/automatize-init-version' of https://github.com/Pi…
Piloalucard 9c14d83
release-tag
Piloalucard fe94a8d
Test, this should trigger to change to prelim automatically
Piloalucard 3f29aba
chore: update version to 2.4.8.4 (Prelim)
github-actions[bot] 07232fe
Test, no change because already prelim
Piloalucard 2de313d
release-tag
Piloalucard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,133 @@ | ||
| name: Sync LTFS Version with Upstream | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update-version: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Fetch latest tag from upstream | ||
| id: get_tag | ||
| run: | | ||
| # Fetch the latest tag from the upstream repository | ||
| LATEST_TAG=$(curl -s https://api.github.com/repos/LinearTapeFileSystem/ltfs/tags | jq -r '.[0].name') | ||
| echo "Latest tag from upstream: $LATEST_TAG" | ||
|
|
||
| # Extract version numbers and build number (e.g., v.2.4.8.2-10520 -> 2.4.8.2 (10520)) | ||
| VERSION_NUM=$(echo "$LATEST_TAG" | sed -E 's/^v\.?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
| BUILD_NUM=$(echo "$LATEST_TAG" | sed -E 's/^v\.?[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-([0-9]+).*/\1/') | ||
|
|
||
| # Combine version with build number | ||
| if [ -n "$BUILD_NUM" ] && [ "$BUILD_NUM" != "$LATEST_TAG" ]; then | ||
| VERSION="$VERSION_NUM ($BUILD_NUM)" | ||
| else | ||
| VERSION="$VERSION_NUM" | ||
| fi | ||
|
|
||
| echo "Extracted version: $VERSION" | ||
|
|
||
| # Store in output | ||
| echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Check current version in configure.ac | ||
| id: check_version | ||
| run: | | ||
| # Extract current version from line 39 | ||
| CURRENT_VERSION=$(sed -n '39p' configure.ac | sed -E 's/.*\[LTFS\], \[([^]]+)\].*/\1/') | ||
| echo "Current version in configure.ac: $CURRENT_VERSION" | ||
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| # Check if commit message contains "release-tag" | ||
| COMMIT_MSG=$(git log -1 --pretty=%B) | ||
| echo "Latest commit message: $COMMIT_MSG" | ||
|
|
||
| if echo "$COMMIT_MSG" | grep -q "release-tag"; then | ||
| echo "Commit contains 'release-tag' keyword - skipping update" | ||
| echo "needs_update=false" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Extract the value inside parentheses from current version | ||
| PAREN_VALUE=$(echo "$CURRENT_VERSION" | sed -E 's/.*\(([^)]+)\).*/\1/') | ||
| echo "Value in parentheses: $PAREN_VALUE" | ||
|
|
||
| # Check if the value in parentheses is a number | ||
| if ! echo "$PAREN_VALUE" | grep -qE '^[0-9]+$'; then | ||
| echo "Value in parentheses is not a number (likely 'Prelim') - no update needed" | ||
| echo "needs_update=false" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Value in parentheses is a number - proceeding with update" | ||
|
|
||
| # Extract version number without parentheses (e.g., "2.4.8.2" from "2.4.8.2 (10520)") | ||
| VERSION_BASE=$(echo "$CURRENT_VERSION" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
| echo "Base version: $VERSION_BASE" | ||
|
|
||
| # Increment the last number in the version | ||
| LAST_NUM=$(echo "$VERSION_BASE" | awk -F. '{print $NF}') | ||
| NEW_LAST_NUM=$((LAST_NUM + 1)) | ||
| NEW_VERSION=$(echo "$VERSION_BASE" | sed -E "s/\.[0-9]+$/.$NEW_LAST_NUM/") | ||
| NEW_VERSION_WITH_PRELIM="$NEW_VERSION (Prelim)" | ||
|
|
||
| echo "New version: $NEW_VERSION_WITH_PRELIM" | ||
| echo "new_version=$NEW_VERSION_WITH_PRELIM" >> $GITHUB_OUTPUT | ||
| echo "needs_update=true" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Update configure.ac | ||
| if: steps.check_version.outputs.needs_update == 'true' | ||
| id: update_file | ||
| run: | | ||
| VERSION="${{ steps.check_version.outputs.new_version }}" | ||
|
|
||
| # Update line 39 with the new version | ||
| sed -i "39s/\[LTFS\], \[[^]]*\]/[LTFS], [$VERSION]/" configure.ac | ||
|
|
||
| echo "File updated successfully" | ||
| echo "Updated line 39:" | ||
| sed -n '39p' configure.ac | ||
|
|
||
| - name: Commit and push changes | ||
| if: steps.check_version.outputs.needs_update == 'true' | ||
| run: | | ||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --local user.name "github-actions[bot]" | ||
|
|
||
| git add configure.ac | ||
| git commit -m "chore: update version to ${{ steps.check_version.outputs.new_version }}" | ||
| git push origin HEAD:${{ github.event.pull_request.head.ref }} | ||
|
|
||
| - name: Summary | ||
| run: | | ||
| echo "## Version Check Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Upstream Tag**: ${{ steps.get_tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Upstream Version**: ${{ steps.get_tag.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Current Version**: ${{ steps.check_version.outputs.current_version }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Update Needed**: ${{ steps.check_version.outputs.needs_update }}" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| if [ "${{ steps.check_version.outputs.needs_update }}" == "true" ]; then | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**configure.ac updated** - Version changed from ${{ steps.check_version.outputs.current_version }} to ${{ steps.check_version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "**No update needed** - Version already has 'Prelim' or commit contains 'release-tag'" >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are getting the release number from the tag it means it won't update when needed since the version number should already be changed before the creation of the tag