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

SP-550 Adds GH tagging #9

Merged
merged 1 commit into from
Apr 17, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Publish
# Build, deploy and attach supported artifacts and draft release tag

on:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/version-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Repo Version Tagging
# This workflow will read the version details from the repo and apply a branch

on:
workflow_dispatch:
inputs:
run_for_real:
required: true
default: false
type: boolean
description: "Apply next tag (or Dry Run)"

jobs:
version-tagging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ secrets.SC_GH_TAG_TOKEN }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 11
- name: Determine Tag
id: taggerVersion
run: |
app_version=$(tools/get_next_version.sh)
echo "New Proposed tag: $app_version"
echo "package_app_version=$app_version" >> $GITHUB_ENV

- name: Apply Tag
if: ${{ inputs.run_for_real }}
id: taggerApply
run: |
echo "Applying tag ${{env.package_app_version}} ..."
git tag "${{env.package_app_version}}"
echo "Pushing changes..."
git push --tags
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Upcoming changes...

## [0.7.2] - 2024-04-17
### Added
- Added [tagging workflow](.github/workflows/version-tag.yml) to aid release generation

## [0.7.1] - 2024-04-12
### Changed
- Update file and winnowing filters
Expand Down Expand Up @@ -86,3 +90,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.6.1]: https://github.com/scanoss/scanoss.java/compare/v0.6.0...v0.6.1
[0.7.0]: https://github.com/scanoss/scanoss.java/compare/v0.6.1...v0.7.0
[0.7.1]: https://github.com/scanoss/scanoss.java/compare/v0.7.0...v0.7.1
[0.7.2]: https://github.com/scanoss/scanoss.java/compare/v0.7.1...v0.7.2
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.scanoss</groupId>
<artifactId>scanoss</artifactId>
<version>0.7.1</version>
<version>0.7.2</version>
<packaging>jar</packaging>
<name>scanoss.java</name>
<url>https://github.com/scanoss/scanoss.java</url>
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/scanoss/TestScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void TestScannerScanFileListPositive() {
List<String> fileList = Arrays.asList(
"src/test/java/com/scanoss/TestScanner.java",
"src/test/java/com/scanoss/TestWinnowing.java",
".github/workflows/release.yml",
".github/workflows/publish.yml",
".gitignore",
"tmp/.gitignore"
);
Expand Down
64 changes: 64 additions & 0 deletions tools/get_next_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
###
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2024, SCANOSS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###
#
# Get the defined package version and compare to the latest tag. Echo the new tag if it doesn't already exist.
#

# Get current directory
export dir=$(dirname "$0")
if [ "$dir" = "" ] ; then
export dir=.
fi


# Get latest git tagged version
version=$(git describe --tags --abbrev=0)
if [[ -z "$version" ]] ; then
version=$(git describe --tags "$(git rev-list --tags --max-count=1)")
fi
if [[ -z "$version" ]] ; then
echo "Error: Failed to determine a valid version number" >&2
exit 1
fi

# Get latest SCANOSS Java version
scanoss_java_version=$(cd "$dir"/.. && ./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [ -z "$scanoss_java_version" ]; then
echo "Error: version not found" >&2
exit 1
fi


semver_scanoss_java="v$scanoss_java_version"

echo "Latest Tag: $version, SCANOSS Java Version: $semver_scanoss_java" >&2

# If the two versions are the same abort, as we don't want to apply the same tag again
if [[ "$version" == "$semver_scanoss_java" ]] ; then
echo "Latest tag and SCANOSS Java version are the same: $version" >&2
exit 1
fi
echo "$semver_scanoss_java"
exit 0
Loading