Skip to content
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

Attempt#4 - Fixing Release Workflow Error #2703

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/create-release-notes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ runs:
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '${{ inputs.tag-name }}',
target_commitish: 'dev',
target_commitish: 'development',
previous_tag_name: '${{ steps.latest-release-tag.outputs.result }}',
})
return data.body.replaceAll('`', '\'').replaceAll('"', '\'')
Expand Down
47 changes: 37 additions & 10 deletions .github/actions/create-release-number/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Create Release Numbers'
description: 'Creates the current release number based on checked out code'
description: 'Creates the current release number based on Gradle or Git history'
outputs:
version-code:
description: 'The numeric app version'
Expand All @@ -10,18 +10,45 @@ outputs:
runs:
using: 'composite'
steps:
- name: Set Build Number
- name: Set Build Number and Version
id: version-generator
shell: bash
run: |
# Try to get version from Gradle
./gradlew versionFile
COMMITS=`git rev-list --count HEAD`
TAGS=`git tag | grep -v beta | wc -l`
GRADLE_VERSION=$(cat version.txt)

if [ "$GRADLE_VERSION" = "unspecified" ] || [ -z "$GRADLE_VERSION" ]; then
echo "Gradle version is unspecified or empty. Generating version from Git."

# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")

# Extract major, minor, patch from the tag
IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST_TAG#v}"

# Count commits since the last tag
COMMITS_SINCE_TAG=$(git rev-list ${LATEST_TAG}..HEAD --count)

# Calculate new patch version
NEW_PATCH=$((PATCH + COMMITS_SINCE_TAG))

# Generate version name
VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
else
echo "Using Gradle-generated version."
VERSION=$GRADLE_VERSION
fi

# Calculate version code
COMMITS=$(git rev-list --count HEAD)
TAGS=$(git tag | grep -v beta | wc -l)
VC=$((((COMMITS+TAGS) * 3) << 1))
echo Number Commits $COMMITS
echo Number Tags $TAGS
echo Version Code $VC

echo "Version: $VERSION"
echo "Number of Commits: $COMMITS"
echo "Number of Tags: $TAGS"
echo "Version Code: $VC"

echo "version-code=$VC" >> $GITHUB_OUTPUT
VERSION=`cat version.txt`
echo Version $VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ plugins {
tasks.register("versionFile") {
group = "publishing"
doLast {
println(project.version)
project.rootProject.file("version.txt").writeText(project.version.toString())
println(project.version.toString())
project.file("version.txt").writeText(project.version.toString())
}
}
6 changes: 3 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement {
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
repositories {
Expand All @@ -26,7 +27,7 @@ extensions.configure<ReckonExtension> {
setDefaultInferredScope("patch")
stages("beta", "final")
setScopeCalc { java.util.Optional.of(org.ajoberstar.reckon.core.Scope.PATCH) }
// setScopeCalc(calcScopeFromProp().or(calcScopeFromCommitMessages()))
setScopeCalc(calcScopeFromProp().or(calcScopeFromCommitMessages()))
setStageCalc(calcStageFromProp())
setTagWriter { it.toString() }
}
Expand Down Expand Up @@ -80,5 +81,4 @@ include(":libs:material3-navigation")
include(":libs:mifos-passcode")

// Kotlin Multiplatform Modules
include(":shared")

include(":shared")
Loading