mirror of
https://github.com/lindbergh-loader/lindbergh-loader.git
synced 2026-09-22 22:48:03 +03:00
Get tag version from changelog.
This commit is contained in:
+57
-24
@@ -51,33 +51,64 @@ jobs:
|
||||
- name: Display Downloaded Artifacts
|
||||
run: find ./artifacts/
|
||||
|
||||
# Step 3: Calculate the next tag version
|
||||
- name: Calculate Next Tag
|
||||
id: calculate_tag # Give the step an ID to potentially reference outputs elsewhere if needed
|
||||
# # Step 3: Calculate the next tag version
|
||||
# - name: Calculate Next Tag
|
||||
# id: calculate_tag # Give the step an ID to potentially reference outputs elsewhere if needed
|
||||
# run: |
|
||||
# echo "Fetching tags..."
|
||||
# git fetch --tags # Ensure all tags are fetched
|
||||
|
||||
# LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)
|
||||
|
||||
# if [[ -z "$LATEST_TAG" ]]; then
|
||||
# # No tags found, start with v1
|
||||
# NEXT_TAG="v1"
|
||||
# echo "No previous tags found. Starting with $NEXT_TAG"
|
||||
# else
|
||||
# echo "Latest tag found: $LATEST_TAG"
|
||||
# # Assuming tag format is 'v' followed by a number (e.g., v1, v123)
|
||||
# # Remove 'v' prefix
|
||||
# CURRENT_VERSION=$(echo $LATEST_TAG | sed 's/^v//')
|
||||
# # Increment the version number
|
||||
# NEXT_VERSION=$((CURRENT_VERSION + 1))
|
||||
# # Add 'v' prefix back
|
||||
# NEXT_TAG="v$NEXT_VERSION"
|
||||
# echo "Calculated next tag: $NEXT_TAG"
|
||||
# fi
|
||||
|
||||
# # Set the calculated tag as an environment variable for subsequent steps
|
||||
# echo "NEXT_TAG=$NEXT_TAG" >> $GITHUB_ENV
|
||||
|
||||
# Step 3: Extract the latest version from changelog.md
|
||||
- name: Extract Version from Changelog
|
||||
id: get_version
|
||||
run: |
|
||||
echo "Fetching tags..."
|
||||
git fetch --tags # Ensure all tags are fetched
|
||||
# Define the path to the changelog file (adjust if it's not at the root)
|
||||
CHANGELOG_FILE="./docs/changelog"
|
||||
|
||||
LATEST_TAG=$(git tag --sort=-creatordate | head -n 1)
|
||||
echo "Attempting to extract version from $CHANGELOG_FILE..."
|
||||
|
||||
if [[ -z "$LATEST_TAG" ]]; then
|
||||
# No tags found, start with v1
|
||||
NEXT_TAG="v1"
|
||||
echo "No previous tags found. Starting with $NEXT_TAG"
|
||||
else
|
||||
echo "Latest tag found: $LATEST_TAG"
|
||||
# Assuming tag format is 'v' followed by a number (e.g., v1, v123)
|
||||
# Remove 'v' prefix
|
||||
CURRENT_VERSION=$(echo $LATEST_TAG | sed 's/^v//')
|
||||
# Increment the version number
|
||||
NEXT_VERSION=$((CURRENT_VERSION + 1))
|
||||
# Add 'v' prefix back
|
||||
NEXT_TAG="v$NEXT_VERSION"
|
||||
echo "Calculated next tag: $NEXT_TAG"
|
||||
# Check if the changelog file exists
|
||||
if [[ ! -f "$CHANGELOG_FILE" ]]; then
|
||||
echo "Error: Changelog file '$CHANGELOG_FILE' not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set the calculated tag as an environment variable for subsequent steps
|
||||
echo "NEXT_TAG=$NEXT_TAG" >> $GITHUB_ENV
|
||||
VERSION=$(awk '/^## \[/ { match($0, /\[([^]]+)\]/, arr); print arr[1]; exit }' "$CHANGELOG_FILE")
|
||||
|
||||
# Check if a version was actually extracted
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
echo "Error: Could not find version in '$CHANGELOG_FILE'. Expected format like '## [X.Y.Z]' near the top."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found version: $VERSION"
|
||||
|
||||
# Set environment variables for the release step
|
||||
# RELEASE_TAG often includes a 'v' prefix, RELEASE_VERSION is the plain version
|
||||
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "RELEASE_TAG=v$VERSION" >> $GITHUB_ENV # Add 'v' prefix for the tag
|
||||
echo "Using tag: v$VERSION"
|
||||
|
||||
# Step 4: Create the release using the calculated tag
|
||||
- name: Create Release
|
||||
@@ -85,11 +116,13 @@ jobs:
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
# Use the environment variable set in the previous step
|
||||
automatic_release_tag: ${{ env.NEXT_TAG }}
|
||||
# automatic_release_tag: ${{ env.NEXT_TAG }}
|
||||
automatic_release_tag: ${{ env.RELEASE_TAG }}
|
||||
# Keep prerelease as false unless you want preview releases
|
||||
prerelease: false
|
||||
# Update the title to use the new tag
|
||||
title: "Build ${{ env.NEXT_TAG }}"
|
||||
# title: "Build ${{ env.NEXT_TAG }}"
|
||||
title: "Build ${{ env.RELEASE_TAG }}"
|
||||
files: |
|
||||
./artifacts/linux-flatpak/lindbergh-loader.flatpak
|
||||
./artifacts/linux-build/build.tar.gz
|
||||
|
||||
Reference in New Issue
Block a user