-
-
Notifications
You must be signed in to change notification settings - Fork 873
.2059806565729300:ea2bd6200ad210607021cd167237f62b_69e3499ab13256d09ece8088.69e3996bb13256d09ece81a4.69e3996a7afba9383018b935:Trae CN.T(2026/4/18 22:47:07) #1271
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,89 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # TODO: Merge with scripts/package/getversion.sh | ||
| # set -e | ||
|
|
||
| if [[ $TRAVIS_TAG ]]; then | ||
| _version=$TRAVIS_TAG; | ||
| elif [[ $APPVEYOR_REPO_TAG_NAME ]]; then | ||
| _version=$APPVEYOR_REPO_TAG_NAME; | ||
| else | ||
| # Exact | ||
| _version=$(git describe --tags --abbrev=0 --exact-match 2>/dev/null) | ||
| if [[ -z $_version ]]; then | ||
| # Latest tag + commit ID | ||
| _version="$(git describe --tags --abbrev=0).dev-$(git rev-parse --short HEAD)" | ||
| SCRIPT_NAME="$(basename "$0")" | ||
| STRIP_V=false | ||
|
|
||
| show_usage() { | ||
| cat << EOF | ||
| Usage: $SCRIPT_NAME [OPTIONS] | ||
|
|
||
| Get the version of ActivityWatch from git tags or CI environment variables. | ||
|
|
||
| Options: | ||
| --strip-v, --no-v Remove the 'v' prefix from the version (if present) | ||
| --help, -h Show this help message | ||
|
|
||
| Environment Variables (used in CI, checked in priority order): | ||
| GITHUB_REF_NAME GitHub Actions tag/ref (e.g., "v0.14.0") | ||
| TRAVIS_TAG Travis CI tag | ||
| APPVEYOR_REPO_TAG_NAME AppVeyor CI tag | ||
|
|
||
| Version Format: | ||
| - Release tag: v0.14.0 | ||
| - Dev version: v0.14.0.dev-abc1234 | ||
| - Beta/RC: v0.14.0b1, v0.14.0rc1 | ||
|
|
||
| Examples: | ||
| $SCRIPT_NAME # v0.14.0 or v0.14.0.dev-abc1234 | ||
| $SCRIPT_NAME --strip-v # 0.14.0 or 0.14.0.dev-abc1234 | ||
| EOF | ||
| } | ||
|
|
||
| parse_args() { | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --strip-v|--no-v) | ||
| STRIP_V=true | ||
| shift | ||
| ;; | ||
| --help|-h) | ||
| show_usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo "ERROR: Unknown argument: $1" >&2 | ||
| show_usage >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
| } | ||
|
|
||
| get_version_internal() { | ||
| local _version="" | ||
|
|
||
| if [[ -n "$GITHUB_REF_NAME" && "$GITHUB_REF_NAME" == v* ]]; then | ||
| _version="$GITHUB_REF_NAME" | ||
| elif [[ -n "$TRAVIS_TAG" ]]; then | ||
| _version="$TRAVIS_TAG" | ||
| elif [[ -n "$APPVEYOR_REPO_TAG_NAME" ]]; then | ||
| _version="$APPVEYOR_REPO_TAG_NAME" | ||
| else | ||
| _version="$(git describe --tags --abbrev=0 --exact-match 2>/dev/null || true)" | ||
| if [[ -z "$_version" ]]; then | ||
| local _latest_tag | ||
| _latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")" | ||
| local _commit_hash | ||
| _commit_hash="$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")" | ||
| _version="${_latest_tag}.dev-${_commit_hash}" | ||
| fi | ||
| fi | ||
|
|
||
| echo "$_version" | ||
| } | ||
|
|
||
| main() { | ||
| parse_args "$@" | ||
|
|
||
| local version | ||
| version="$(get_version_internal)" | ||
|
|
||
| if $STRIP_V; then | ||
| version="$(echo "$version" | sed -e 's/^v//')" | ||
| fi | ||
| fi | ||
|
|
||
| echo "$version" | ||
| } | ||
|
|
||
| echo $_version; | ||
| main "$@" |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,15 @@ | ||||||||||
| #!/usr/bin/bash | ||||||||||
| # Setting the shell is required, as `sh` doesn't support slicing. | ||||||||||
|
|
||||||||||
| # Fail fast | ||||||||||
| set -e | ||||||||||
| # Verbose commands for CI verification | ||||||||||
| set -x | ||||||||||
|
|
||||||||||
| VERSION=$(scripts/package/getversion.sh) | ||||||||||
| # Slice off the "v" from the tag, which is probably guaranteed | ||||||||||
| VERSION_NUM=${VERSION:1} | ||||||||||
| echo $VERSION_NUM | ||||||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||||||
| VERSION="$("$SCRIPT_DIR/getversion.sh")" | ||||||||||
| VERSION_NUM="$("$SCRIPT_DIR/getversion.sh" --strip-v)" | ||||||||||
| echo "Version (with v): $VERSION" | ||||||||||
|
Comment on lines
+10
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The same pattern also appears in both workflow files (lines 62-63 in |
||||||||||
| echo "Version (without v): $VERSION_NUM" | ||||||||||
| PKGDIR="activitywatch_$VERSION_NUM" | ||||||||||
|
|
||||||||||
| # Package tools | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v-prefix requirementThe deleted line explained why the
vprefix must be stripped for the Windows installer:This is a non-obvious requirement and the link to the winget-pkgs PR was valuable context for future maintainers. Consider restoring it near the
build_setupfunction or theversion_no_prefixassignment at the top of the file.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!