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
c2c71cd8
Verified
Commit
c2c71cd8
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: update ci #14
parent
9216f597
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+3
-3
3 additions, 3 deletions
.gitlab-ci.yml
devenv.nix
+117
-103
117 additions, 103 deletions
devenv.nix
project.nix
+1
-1
1 addition, 1 deletion
project.nix
treefmt.toml
+1
-1
1 addition, 1 deletion
treefmt.toml
with
122 additions
and
108 deletions
.gitlab-ci.yml
+
3
−
3
View file @
c2c71cd8
...
...
@@ -17,10 +17,10 @@
-
release
# if you want to debug the ci pipeline, uncomment the following lines
#debug:
#debug:
# tags:
# - nixos
# stage: tag
# stage: tag
# script:
# - export
...
...
@@ -45,7 +45,7 @@
-
nixos
stage
:
release
rules
:
-
if
:
'
$CI_COMMIT_TAG_MESSAGE
=~
/DO_RELEASE/'
-
if
:
'
$CI_COMMIT_TAG_MESSAGE
=~
/DO_RELEASE/'
when
:
on_success
-
when
:
never
variables
:
...
...
This diff is collapsed.
Click to expand it.
devenv.nix
+
117
−
103
View file @
c2c71cd8
...
...
@@ -8,55 +8,52 @@
modulesPath
,
...
}:
let
taskfileYaml
=
let
ciJobToken
=
builtins
.
getEnv
"CI_JOB_TOKEN"
;
gitCommit
=
if
ciJobToken
==
""
then
(
builtins
.
getFlake
"git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes"
)
.
packages
.
${
builtins
.
currentSystem
}
.
git-commit
else
""
;
gitCommit
=
if
ciJobToken
==
""
then
(
builtins
.
getFlake
"git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes"
)
.
packages
.
${
builtins
.
currentSystem
}
.
git-commit
else
""
;
goPkgReleaseData
=
import
./project.nix
;
goPkgName
=
goPkgReleaseData
.
name
or
"goPkg"
;
goPkgMnemonic
=
goPkgReleaseData
.
mnemonic
or
"go-pkg"
;
goPkgMnemonic
=
goPkgReleaseData
.
mnemonic
or
"go-pkg"
;
in
pkgs
.
writeTextFile
{
name
=
"Taskfile.yaml"
;
text
=
''
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
version: '3'
tasks:
build:
desc: Build the app
aliases:
- b
cmds:
- build-app
sources:
- source/*.go
- source/**/*.go
- source/go.mod
- dist/**
git-commit:
desc: Commit changes to git
cmds:
-
${
gitCommit
}
/bin/git-commit
silent: true
default:
desc: Print this help message
aliases: [d, help]
cmds:
- task --list
silent: true
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
''
;
};
pkgs
.
writeTextFile
{
name
=
"Taskfile.yaml"
;
text
=
''
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
version: '3'
tasks:
build:
desc: Build the app
aliases:
- b
cmds:
- build-app
sources:
- source/*.go
- source/**/*.go
- source/go.mod
- dist/**
git-commit:
desc: Commit changes to git
cmds:
-
${
gitCommit
}
/bin/git-commit
silent: true
default:
desc: Print this help message
aliases: [d, help]
cmds:
- task --list
silent: true
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
''
;
};
treefmtConfig
=
pkgs
.
writeTextFile
{
name
=
"treefmt.toml"
;
...
...
@@ -67,7 +64,7 @@ tasks:
command = "
${
pkgs
.
alejandra
}
/bin/alejandra"
options = []
includes = [ "*.nix" ]
excludes = [ "devenv.nix" ]
#
excludes = [ "devenv.nix" ]
[formatter.go]
command = "
${
pkgs
.
go
}
/bin/gofmt"
...
...
@@ -135,10 +132,10 @@ tasks:
- release
# if you want to debug the ci pipeline, uncomment the following lines
#debug:
#debug:
# tags:
# - nixos
# stage: tag
# stage: tag
# script:
# - export
...
...
@@ -163,7 +160,7 @@ tasks:
- nixos
stage: release
rules:
- if: '$CI_COMMIT_TAG_MESSAGE =~ /DO_RELEASE/'
- if: '$CI_COMMIT_TAG_MESSAGE =~ /DO_RELEASE/'
when: on_success
- when: never
variables:
...
...
@@ -176,54 +173,55 @@ tasks:
''
;
};
goReleaserYaml
=
let
goReleaserYaml
=
let
goPkgReleaseData
=
import
./project.nix
;
goPkgName
=
goPkgReleaseData
.
name
or
"goPkg"
;
goPkgMnemonic
=
goPkgReleaseData
.
mnemonic
or
"go-pkg"
;
in
pkgs
.
writeTextFile
{
name
=
".goreleaser.yml"
;
text
=
''
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
gitlab_urls:
api: https://gitlab.schukai.com/api/v4
download: https://gitlab.schukai.com
pkgs
.
writeTextFile
{
name
=
".goreleaser.yml"
;
text
=
''
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
gitlab_urls:
api: https://gitlab.schukai.com/api/v4
download: https://gitlab.schukai.com
# set to true if you use a self-signed certificate
skip_tls_verify: false
# set to true if you use a self-signed certificate
skip_tls_verify: false
use_package_registry: true
use_package_registry: true
# Set this if you set GITLAB_TOKEN to the value of CI_JOB_TOKEN.
# Since: v1.11
use_job_token: false
# Set this if you set GITLAB_TOKEN to the value of CI_JOB_TOKEN.
# Since: v1.11
use_job_token: false
project_name:
${
goPkgMnemonic
}
project_name:
${
goPkgMnemonic
}
builds:
- id:
${
goPkgMnemonic
}
goos:
- linux
- darwin
- 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
}
'
builds:
- id:
${
goPkgMnemonic
}
goos:
- linux
- darwin
- 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
}
'
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
''
;
};
## DO NOT EDIT THIS FILE MANUALLY, IT IS GENERATED BY NIX
''
;
};
in
{
env
.
APP_NAME
=
let
goPkgReleaseData
=
import
./project.nix
;
goPkgMnemonic
=
goPkgReleaseData
.
mnemonic
or
"go-pkg"
;
in
goPkgMnemonic
;
env
.
APP_NAME
=
let
goPkgReleaseData
=
import
./project.nix
;
goPkgMnemonic
=
goPkgReleaseData
.
mnemonic
or
"go-pkg"
;
in
goPkgMnemonic
;
# https://devenv.sh/packages/
packages
=
with
pkgs
;
[
...
...
@@ -302,7 +300,7 @@ in {
echo " ✖ Not in gitlab ci."
exit 0
fi
set -x
${
pkgs
.
git
}
/bin/git config user.email "
''$
{GITLAB_USER_EMAIL}"
${
pkgs
.
git
}
/bin/git config user.name "
''$
{GITLAB_USER_NAME:-"Gitlab CI"}"
...
...
@@ -314,29 +312,29 @@ in {
${
pkgs
.
git
}
/bin/git reset --hard origin/master
${
pkgs
.
git
}
/bin/git checkout $CI_COMMIT_REF_NAME
${
pkgs
.
git
}
/bin/git pull origin $CI_COMMIT_REF_NAME
NEWVERSION=$(
${
inputs
.
version
.
defaultPackage
.
"
${
builtins
.
currentSystem
}
"
}
/bin/version predict --git exit-code-if-no-bump)
if [[ $? -ne 0 ]]; then
echo " ✖ No bump wanted."
exit 0
fi
if [[ -z "
''$
{NEWVERSION}" ]]; then
echo " ✖ No version found."
exit 0
fi
sed -i "s/version\s*=\s*\".*\"/version
=
\"
''$
{NEWVERSION}\"/"
${
config
.
devenv
.
root
}
/project.nix
sed -i "s/version\s*=\s*\".*\"/version
=
\"
''$
{NEWVERSION}\"/"
${
config
.
devenv
.
root
}
/project.nix
${
pkgs
.
git
}
/bin/git add
${
config
.
devenv
.
root
}
/project.nix
${
pkgs
.
git
}
/bin/git commit -m "chore: Bump version to
''$
{NEWVERSION}"
${
pkgs
.
git
}
/bin/git log --decorate=short --pretty=oneline
${
pkgs
.
git
}
/bin/git tag -a "
''$
{NEWVERSION}" -m "chore: Release
''$
{NEWVERSION} - DO_RELEASE"
${
pkgs
.
git
}
/bin/git push origin $CI_COMMIT_REF_NAME --tags
''
;
scripts
.
common-functions
.
exec
=
''
if [ -t 1 ]; then
...
...
@@ -373,15 +371,15 @@ in {
fi
echo "$hash"
}
echo_green() {
echo -e "$GREEN ✔ $1$RESET"
}
echo_red() {
echo -e "$RED ✖ $1$RESET"
}
echo_todo() {
echo_bold "$BLUE • $1"
}
...
...
@@ -397,11 +395,11 @@ in {
${
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
...
...
@@ -424,8 +422,7 @@ in {
fi
''
;
scripts
.
update-files
.
exec
=
''
#!
${
pkgs
.
bash
}
/bin/bash
source common-functions
...
...
@@ -436,7 +433,7 @@ in {
echo_red "$2 already exists"
fi
}
update_symlink() {
echo -e " → $1"
local source_path="$1"
...
...
@@ -448,7 +445,7 @@ in {
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"
...
...
@@ -495,6 +492,23 @@ in {
echo "$hash"
''
;
## this script should be run after debugging the ci pipeline
scripts
.
delete-pipeline
.
exec
=
''
#!
${
pkgs
.
bash
}
/bin/bash
pipeline_list=$(glab ci list)
commit_hashes=$(echo "$pipeline_list" | awk '/#/{print $3}')
for hash in $commit_hashes; do
hh=$(echo "$hash" | cut -d"#" -f2)
echo "found hash: $hh"
glab ci delete "$hh"
done
echo "done"
''
;
scripts
.
build-app
.
exec
=
''
#!
${
pkgs
.
bash
}
/bin/bash
${
pkgs
.
treefmt
}
/bin/treefmt
...
...
@@ -509,9 +523,9 @@ in {
scripts
.
update-hashes
.
exec
=
''
#!
${
pkgs
.
bash
}
/bin/bash
sed -i 's/vendorHash\s*=\s*".*"/vendorHash
=
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="/'
${
config
.
devenv
.
root
}
/project.nix
sed -i 's/vendorHash\s*=\s*".*"/vendorHash
=
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="/'
${
config
.
devenv
.
root
}
/project.nix
HASH=$(
${
pkgs
.
nix
}
/bin/nix build 2>&1 | grep 'got:' | awk '{print $2}')
sed -i "s/vendorHash\s*=\s*\".*\"/vendorHash
=
\"
''$
{HASH}\"/"
${
config
.
devenv
.
root
}
/project.nix
sed -i "s/vendorHash\s*=\s*\".*\"/vendorHash
=
\"
''$
{HASH}\"/"
${
config
.
devenv
.
root
}
/project.nix
''
;
enterShell
=
''
...
...
This diff is collapsed.
Click to expand it.
project.nix
+
1
−
1
View file @
c2c71cd8
...
...
@@ -6,5 +6,5 @@
compileForSystems
=
[
"linux/arm64"
"linux/amd64"
"darwin/amd64"
"windows/amd64"
];
modulePath
=
"gitlab.schukai.com/oss/utilities/version"
;
version
=
"0.7.7"
;
## don't change this line, it is updated automatically by GitLab CI
vendorHash
=
"sha256-uyWI6Gnko1J62XDk6jjRdqZ8TSFtwsTOlDwdR9Xc+ic="
;
## this is updated automatically by update-hashes
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 @
c2c71cd8
/nix/store/wrp2lsy6h8mzr6fa4n71lqnxw5dliwmc-treefmt.toml
\ No newline at end of file
/nix/store/f7brr7ah00s9303lhvk338lnyb1ifrys-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