Skip to content

Commit

Permalink
Merge pull request #267 from lcarva/fix-release
Browse files Browse the repository at this point in the history
Increment release version by one from previous tag
  • Loading branch information
lcarva authored Feb 5, 2024
2 parents 177f52f + 2817d78 commit 74bb231
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ jobs:
set -o pipefail
set -o nounset
latest=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo api/v0.1.0)
echo "version="${latest%.*}".$(git rev-list --count "${latest}"..HEAD || echo 0)" >> "$GITHUB_ENV"
echo "version=$(./hack/next-version.sh)" >> "$GITHUB_ENV"
- name: API Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
Expand Down
44 changes: 44 additions & 0 deletions hack/next-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Copyright The Enterprise Contract Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

# TODO: Add usage

set -o errexit
set -o pipefail
set -o nounset

function debug() {
>&2 echo "DEBUG: ${1}"
}

# E.g. api/v0.1.33
latest_version="$(git tag | sort -V -r | head -n 1)"
debug "Latest version: ${latest_version}"

latest_patch_version="$(echo -n ${latest_version} | cut -d. -f3)"
debug "Latest patch version: ${latest_patch_version}"

version_prefix="$(echo -n ${latest_version} | cut -d. -f1-2)"
debug "Version prefix: ${version_prefix}"

next_patch_version="$((${latest_patch_version}+1))"
debug "Next patch version: ${latest_patch_version}"

next_version="${version_prefix}.${next_patch_version}"
debug "Next version is: ${next_version}"

echo -n "${next_version}"

0 comments on commit 74bb231

Please sign in to comment.