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

Update CI to Handle No dev Branch #3

Merged
merged 6 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
58 changes: 46 additions & 12 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,34 @@ jobs:
path: target/
- name: Get Tagged Version
id: lasttag
if: ${{ endsWith(github.base_ref, 'main') && contains(github.head_ref, 'release') }}
if: ${{ endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/') || github.event.pull_request.merged) }}
run: |
git config --global --add safe.directory "$PWD"
apt-get update && apt-get install -yqq jq
COMMIT="${{github.sha}}"
V="${{github.head_ref}}"
V="${V#release/v}"
if ${{contains(github.head_ref, 'release')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')"
V=v${V//\"/} #remove '"'s
fi

if ${{! github.event.pull_request.merged}}; then
V="${V}-$(git tag --list v${V}* | wc -l)"
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi

CL=${V}
# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
fi

CL=${V#v}
CL=${CL%-*}

echo "version=${V}" >> $GITHUB_OUTPUT
Expand All @@ -252,7 +268,7 @@ jobs:

publish:
name: Publish
if: ${{ endsWith(github.base_ref, 'main') && contains(github.head_ref, 'release') }}
if: ${{ endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/') || github.event.pull_request.merged) }}
needs:
- build
- lint
Expand Down Expand Up @@ -304,7 +320,7 @@ jobs:
- code_coverage
- package
- sbom
if: ${{ endsWith(github.base_ref, 'main') && contains(github.head_ref, 'release') }}
if: ${{ endsWith(github.base_ref, 'main') && (contains(github.head_ref, 'release/') || github.event.pull_request.merged) }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -314,11 +330,28 @@ jobs:
- name: Get Tagged Version
id: lasttag
run: |
git config --global --add safe.directory "$PWD"
apt-get install -yqq jq
COMMIT="${{github.sha}}"
V="${{github.head_ref}}"
V="${V#release/}"
if ${{contains(github.head_ref, 'release/')}}; then
V="${{github.head_ref}}"
V="${V#release/}"
else
V="$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')"
V=v${V//\"/} #remove '"'s
fi

if ${{! github.event.pull_request.merged}}; then
# Check to see if the version tag already exists
# If it does, print a message and exit with an error code
if [ $(git tag --list "$V") ]; then
echo "Version tag already exists. Did you bump the version number?"
exit 1
fi

# Create an RC release if
# 1) This PR is a release branch that hasn't been merged to main.
# 2) This is a feature branch being merged into the main branch.
if ${{(! github.event.pull_request.merged && contains(github.head_ref, 'release/')) || (github.event.pull_request.merged && !contains(github.head_ref, 'release/'))}}; then
V="${V}-$(git tag --list ${V}* | wc -l)"
fi

Expand All @@ -328,6 +361,7 @@ jobs:
echo "version=${V}" >> $GITHUB_OUTPUT
echo "cl_version=${CL}" >> $GITHUB_OUTPUT
echo "commit=${COMMIT}" >> $GITHUB_OUTPUT

- run: 'git tag --list ${V}*'
- name: Get Artifacts
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -362,7 +396,7 @@ jobs:

${{steps.changelog.outputs.description}}

prerelease: ${{! github.event.pull_request.merged}}
prerelease: ${{(! github.event.pull_request.merged) || (github.event.pull_request.merged && ! contains(github.head_ref, 'release/'))}}
commit: ${{steps.lasttag.outputs.commit}}
makeLatest: true
tag: ${{steps.lasttag.outputs.version}}
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
Fixed -- for any bug fixes.
Security -- in case of vulnerabilities.
-->
## [0.15.1]

## [0.15.0]

### Fixed
Expand Down Expand Up @@ -74,7 +76,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
- Feature to retrieve TSP-Link network details

<!--Version Comparison Links-->
[Unreleased]: https://github.com/tektronix/tsp-toolkit-kic-cli/compare/v0.15.0...HEAD
[Unreleased]: https://github.com/tektronix/tsp-toolkit-kic-cli/compare/v0.15.1...HEAD
[0.15.1]: https://github.com/tektronix/tsp-toolkit-kic-cli/releases/tag/v0.15.1
[0.15.0]: https://github.com/tektronix/tsp-toolkit-kic-cli/releases/tag/v0.15.0
[0.14.1]: https://github.com/tektronix/tsp-toolkit-kic-cli/releases/tag/v0.14.1
[0.13.2]: https://github.com/tektronix/tsp-toolkit-kic-cli/releases/tag/v0.13.2
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.15.0"
version = "0.15.1"
authors = ["Keithley Instruments, LLC"]
edition = "2021"
repository = "https://github.com/tektronix/tsp-toolkit-kic-cli"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tektronix/kic-cli",
"version": "0.15.0",
"version": "0.15.1",
"main": "index.js",
"bin": {
"windows-kic": "./bin/kic.exe",
Expand Down
Loading