Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Version
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Utilities
Version
Commits
e76c2200
Verified
Commit
e76c2200
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: update ci tools #7
parent
96877fcc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
devenv.nix
+139
-32
139 additions, 32 deletions
devenv.nix
project.nix
+2
-2
2 additions, 2 deletions
project.nix
treefmt.toml
+1
-1
1 addition, 1 deletion
treefmt.toml
with
142 additions
and
35 deletions
devenv.nix
+
139
−
32
View file @
e76c2200
...
...
@@ -46,13 +46,6 @@ tasks:
cmds:
-
${
gitCommit
}
/bin/git-commit
silent: true
commit:
desc: Commit a feature
cmds:
- do-git-commit
silent: true
default:
desc: Print this help message
...
...
@@ -66,7 +59,7 @@ tasks:
};
treefmtConfig
=
pkgs
.
writeTextFile
{
name
=
"
Taskfile.ya
ml"
;
name
=
"
treefmt.to
ml"
;
text
=
''
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
...
...
@@ -208,7 +201,12 @@ tasks:
- windows
dir:
${
config
.
devenv
.
root
}
/source
ldflags:
- -s -w -X main.version={{.Version}} -X 'main.commit={{.Commit}}' -X 'main.build={{.Date}}' -X 'main.mnemonic=
${
goPkgMnemonic
}
' -X 'main.name=
${
goPkgName
}
'
- -s -w
- -X main.version={{.Version}}
- -X 'main.commit={{.Commit}}'
- -X 'main.build={{.Date}}'
- -X 'main.mnemonic=
${
goPkgMnemonic
}
'
- -X 'main.name=
${
goPkgName
}
'
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
...
...
@@ -331,33 +329,142 @@ in {
${
pkgs
.
git
}
/bin/git push origin $CI_COMMIT_REF_NAME --tags
''
;
scripts
.
common-functions
.
exec
=
''
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RESET='\033[0m'
BOLD='\033[1m'
else
RED=""
GREEN=""
RESET=""
fi
is_true() {
val="$1"
if [ "$val" = 'true' ] || [ "$val" = '1' ]; then
return 0
else
return 1
fi
}
get_commit_hash() {
hash=""
if [[ -n "$CI_COMMIT_SHORT_SHA" ]]; then
hash="$CI_COMMIT_SHORT_SHA"
else
hash="$(git rev-parse --short HEAD)"
if [[ -n "$(git status --porcelain)" ]]; then
hash="
''$
{hash}-dirty"
fi
fi
echo "$hash"
}
echo_green() {
echo -e "$GREEN ✔ $1$RESET"
}
echo_red() {
echo -e "$RED ✖ $1$RESET"
}
echo_todo() {
echo_bold "$BLUE • $1"
}
update_project_version() {
if version auto --git --exit-code-if-no-bump --verbose
then
buildVer=$(version print --git)
local project_nix="
${
config
.
devenv
.
root
}
/project.nix"
sed -i "s/^\s*version\s*=.*/ version = \"$buildVer\";/" "$project_nix"
echo_green "Project version updated to $buildVer"
${
pkgs
.
git
}
/bin/git add "$project_nix"
${
pkgs
.
git
}
/bin/git commit -m "chore: Update project version to $buildVer" "$project_nix"
${
pkgs
.
git
}
/bin/git tag -f -a "$buildVer" -m "Release $buildVer"
if is_true "$CI_MODE"; then
${
pkgs
.
git
}
/bin/git push -o ci.skip origin
''$
{CI_COMMIT_REF_NAME} --tags
fi
else
echo_green "Project version is up to date"
fi
}
get_project_version() {
echo "$(version print --git)"
}
if [ -z "$DEBUG_MODE" ]; then
DEBUG_MODE='false'
fi
if [ -n "$CI_JOB_TOKEN" ]; then
CI_MODE='true'
fi
if is_true "$DEBUG_MODE" || is_true "$CI_MODE"; then
set -x
fi
''
;
scripts
.
update-files
.
exec
=
''
#!
${
pkgs
.
bash
}
/bin/bash
update_symlink() {
local source_path="$1"
local target_path="$2"
local file_name="$(basename "$target_path")"
if [[ -L "$source_path" ]]; then
if [[ "$(readlink "$source_path")" != "$target_path" ]]; then
# Link exists but is not up to date
rm "$source_path"
ln -s "$target_path" "$source_path"
fi
elif [[ -e "$source_path" ]]; then
echo "$file_name already exists. Please rename or delete it."
exit 1
else
ln -s "$target_path" "$source_path"
fi
}
source common-functions
create_symlink() {
if ln -s "$1" "$2" 2>/dev/null; then
echo_green "$2 created"
else
echo_red "$2 already exists"
fi
}
update_symlink() {
echo -e " → $1"
local source_path="$1"
local target_path="$2"
local file_name="$(basename "$target_path")"
local source_dir="$(dirname "$source_path")"
mkdir -p "$source_dir" || true
if [[ ! -d "$source_dir" ]]; then
echo_red "$RED ✖ $source_dir is not a directory. Please remove it manually and run the script again."
exit 1
fi
if [[ -L "$source_path" ]]; then
if [[ "$(readlink "$source_path")" != "$target_path" ]]; then
rm "$source_path"
create_symlink "$target_path" "$source_path"
echo_green "$GREEN ✔ $source_path updated$RESET"
else
echo_green "$GREEN ✔ $source_path is up to date$RESET"
fi
elif [[ -e "$source_path" ]]; then
echo_red "$RED ✖ $source_path already exists and is not a symlink. Please remove it manually and run the script again."
exit 1
else
create_symlink "$target_path" "$source_path"
fi
}
# Usage for Taskfile.yaml
update_symlink "
${
config
.
devenv
.
root
}
/Taskfile.yaml" "
${
taskfileYaml
}
"
update_symlink "
${
config
.
devenv
.
root
}
/.goreleaser.yml" "
${
goReleaserYaml
}
"
update_symlink "
${
config
.
devenv
.
root
}
/treefmt.toml" "
${
treefmtConfig
}
"
# Usage for Taskfile.yaml
update_symlink "
${
config
.
devenv
.
root
}
/Taskfile.yaml" "
${
taskfileYaml
}
"
update_symlink "
${
config
.
devenv
.
root
}
/.goreleaser.yml" "
${
goReleaserYaml
}
"
update_symlink "
${
config
.
devenv
.
root
}
/treefmt.toml" "
${
treefmtConfig
}
"
cat
${
gitlabCiYaml
}
> "
${
config
.
devenv
.
root
}
/.gitlab-ci.yml"
cat
${
gitlabCiYaml
}
> "
${
config
.
devenv
.
root
}
/.gitlab-ci.yml"
''
;
...
...
This diff is collapsed.
Click to expand it.
project.nix
+
2
−
2
View file @
e76c2200
...
...
@@ -5,6 +5,6 @@
supportedSystems
=
[
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
compileForSystems
=
[
"linux/arm64"
"linux/amd64"
"darwin/amd64"
"windows/amd64"
];
modulePath
=
"gitlab.schukai.com/oss/utilities/version"
;
version
=
"0.6.26"
;
## don't change this line, it is updated automatically by GitLab CI
vendorHash
=
"sha256-uyWI6Gnko1J62XDk6jjRdqZ8TSFtwsTOlDwdR9Xc+ic="
;
## this is updated automatically by update-hashes
version
=
"0.6.26"
;
## don't change this line, it is updated automatically by GitLab CI
vendorHash
=
"sha256-uyWI6Gnko1J62XDk6jjRdqZ8TSFtwsTOlDwdR9Xc+ic="
;
## this is updated automatically by update-hashes
}
This diff is collapsed.
Click to expand it.
treefmt.toml
+
1
−
1
View file @
e76c2200
/nix/store/smqjqjy0wa39nvk52jq6x8w1i4bs65g9-Taskfile.yaml
\ No newline at end of file
/nix/store/wrp2lsy6h8mzr6fa4n71lqnxw5dliwmc-treefmt.toml
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment