Skip to content
Snippets Groups Projects
Verified Commit db550e83 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: test goreleaser

parent 7f446555
No related branches found
No related tags found
No related merge requests found
...@@ -11,57 +11,73 @@ variables: ...@@ -11,57 +11,73 @@ variables:
NIXPKGS_ALLOW_UNFREE: "1" NIXPKGS_ALLOW_UNFREE: "1"
NIXPKGS_ALLOW_INSECURE: "1" NIXPKGS_ALLOW_INSECURE: "1"
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
GIT_DEPTH: 10 #GIT_DEPTH: 10
stages: stages:
- build # - build
- deploy # - deploy
- release
before_script:
- nix shell nixpkgs#coreutils-full -c mkdir -p /certs/client/ release:
- nix shell nixpkgs#coreutils-full -c ln -fs /etc/ssl/certs/ca-bundle.crt /certs/client/ca.pem stage: release
- echo > .env-gitlab-ci image:
- variables=("HOME=$HOME" "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" "CI_REPOSITORY_URL=$CI_REPOSITORY_URL" "GITLAB_TOKEN=$GITLAB_TOKEN" "CI_JOB_TOKEN=$CI_JOB_TOKEN" "GITLAB_USER_EMAIL=$GITLAB_USER_EMAIL" "GITLAB_USER_NAME=\"$GITLAB_USER_NAME\"" "CI_REGISTRY_USER=$CI_REGISTRY_USER" "CI_PROJECT_ID=$CI_PROJECT_ID" "CI_PROJECT_DIR=$CI_PROJECT_DIR" "CI_API_V4_URL=$CI_API_V4_URL" "CI_PROJECT_NAME=$CI_PROJECT_NAME" "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA"); for var in "${variables[@]}"; do echo "$var" >> .env-gitlab-ci; done name: goreleaser/goreleaser
- cat .env-gitlab-ci entrypoint: ['']
only:
after_script: - tags
- if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi variables:
# Disable shallow cloning so that goreleaser can diff between tags to
build: # generate a changelog.
stage: build GIT_DEPTH: 0
tags:
- nixos
script:
- devenv shell build-app
cache:
- key: nixos
paths:
- /nix/store
artifacts:
paths:
- dist
deploy:
stage: deploy
tags:
- nixos
script: script:
- devenv shell -c deploy-app - goreleaser release --clean
when: on_success
#before_script:
cache: # - nix shell nixpkgs#coreutils-full -c mkdir -p /certs/client/
- key: nixos # - nix shell nixpkgs#coreutils-full -c ln -fs /etc/ssl/certs/ca-bundle.crt /certs/client/ca.pem
paths: # - echo > .env-gitlab-ci
- /nix/store # - variables=("HOME=$HOME" "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" "CI_REPOSITORY_URL=$CI_REPOSITORY_URL" "GITLAB_TOKEN=$GITLAB_TOKEN" "CI_JOB_TOKEN=$CI_JOB_TOKEN" "GITLAB_USER_EMAIL=$GITLAB_USER_EMAIL" "GITLAB_USER_NAME=\"$GITLAB_USER_NAME\"" "CI_REGISTRY_USER=$CI_REGISTRY_USER" "CI_PROJECT_ID=$CI_PROJECT_ID" "CI_PROJECT_DIR=$CI_PROJECT_DIR" "CI_API_V4_URL=$CI_API_V4_URL" "CI_PROJECT_NAME=$CI_PROJECT_NAME" "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA"); for var in "${variables[@]}"; do echo "$var" >> .env-gitlab-ci; done
# - cat .env-gitlab-ci
#
artifacts: #after_script:
paths: # - if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi
- dist #
#build:
# stage: build
# tags:
# - nixos
# script:
# - devenv shell build-app
#
# cache:
# - key: nixos
# paths:
# - /nix/store
#
# artifacts:
# paths:
# - dist
#
#deploy:
# stage: deploy
# tags:
# - nixos
# script:
# - devenv shell -c deploy-app
#
# when: on_success
#
# cache:
# - key: nixos
# paths:
# - /nix/store
#
#
# artifacts:
# paths:
# - dist
/nix/store/jdfscwlv8d8nqn5alv0sbnfp93w30af1-goreleaser.yml
\ No newline at end of file
/nix/store/pglnb1wn54s3y2c2p56av41rq8q9zhz8-Taskfile.yaml /nix/store/lfy3spmspb2bnzwg8359nn58q1hzdyv5-Taskfile.yaml
\ No newline at end of file \ No newline at end of file
...@@ -8,31 +8,31 @@ COMPONENT_SLUG=$3 ...@@ -8,31 +8,31 @@ COMPONENT_SLUG=$3
GO_RELEASE_PACKAGE_NAME=$4 GO_RELEASE_PACKAGE_NAME=$4
PROJECT_VERSION=$5 PROJECT_VERSION=$5
PROJECT_BUILD_DATE=$6 PROJECT_BUILD_DATE=$6
platforms=$(go tool dist list) platforms=("x86_64/linux" "x86_64/darwin" "aarch64/linux" "aarch64/darwin" "amd64/linux")
included_os=("linux" "windows") #included_os=("linux" "windows")
# define a list of excluded architectures # define a list of excluded architectures
included_arch=("amd64" "arm64") #included_arch=("amd64" "arm64" "x86_64")
cd $SOURCE_PATH || exit 1 cd $SOURCE_PATH || exit 1
# Run and build loop through all platforms (except excluded ones) # Run and build loop through all platforms (except excluded ones)
for platform in $platforms; do for platform in ${platforms[@]}; do
# GOOS und GOARCH Variablen setzen # GOOS und GOARCH Variablen setzen
export GOOS=$(echo $platform | cut -d'/' -f1) export GOARCH=$(echo $platform | cut -d'/' -f1)
export GOARCH=$(echo $platform | cut -d'/' -f2) export GOOS=$(echo $platform | cut -d'/' -f2)
if [[ ! "${included_os[@]}" =~ "$GOOS" ]]; then # if [[ ! "${included_os[@]}" =~ "$GOOS" ]]; then
echo "Skipping excluded platform: $GOOS" # echo "Skipping excluded platform: $GOOS"
continue # continue
fi # fi
if [[ ! "${included_arch[@]}" =~ "$GOARCH" ]]; then # if [[ ! "${included_arch[@]}" =~ "$GOARCH" ]]; then
echo "Skipping excluded architecture: $GOARCH" # echo "Skipping excluded architecture: $GOARCH"
continue # continue
fi # fi
echo "============================================" echo "============================================"
echo "Building for $GOOS/$GOARCH" echo "Building for $GOOS/$GOARCH"
......
...@@ -14,10 +14,6 @@ tasks: ...@@ -14,10 +14,6 @@ tasks:
desc: Build the app desc: Build the app
aliases: aliases:
- b - b
vars:
DEVENV_ROOT:
sh: echo "$DEVENV_ROOT"
cmds: cmds:
- devenv shell build-app - devenv shell build-app
sources: sources:
...@@ -42,6 +38,28 @@ tasks: ...@@ -42,6 +38,28 @@ tasks:
}; };
goReleaserYaml = pkgs.writeTextFile {
name = ".goreleaser.yml";
text = ''
# .goreleaser.yml
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
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
'';
};
in in
...@@ -53,6 +71,8 @@ tasks: ...@@ -53,6 +71,8 @@ tasks:
packages = with pkgs; [ packages = with pkgs; [
inputs.version.defaultPackage."${builtins.currentSystem}" inputs.version.defaultPackage."${builtins.currentSystem}"
appimage-run appimage-run
goreleaser
go-tools
awscli2 awscli2
blackbox blackbox
blackbox-terminal blackbox-terminal
...@@ -139,8 +159,7 @@ tasks: ...@@ -139,8 +159,7 @@ tasks:
# Usage for Taskfile.yaml # Usage for Taskfile.yaml
update_symlink "${config.devenv.root}/Taskfile.yaml" "${taskfileYaml}" update_symlink "${config.devenv.root}/Taskfile.yaml" "${taskfileYaml}"
update_symlink "${config.devenv.root}/.goreleaser.yml" "${goReleaserYaml}"
''; '';
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
rootPath = ./.; rootPath = ./.;
# System types to support. # System types to support.
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; supportedSystems = [ "x86_64-linux" "x86_64-windows" "x86_64-darwin" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
# In 'nix develop', we don't need a copy of the source tree # In 'nix develop', we don't need a copy of the source tree
# in the Nix store. # in the Nix store.
src = ././source; src = ././source;
tags = []; # add your tags here (eq "netgo" "osusergo" "static_build")
# This hash locks the dependencies of this package. It is # This hash locks the dependencies of this package. It is
# necessary because of how Go requires network access to resolve # necessary because of how Go requires network access to resolve
...@@ -46,7 +47,8 @@ ...@@ -46,7 +47,8 @@
# remeber to bump this hash when your dependencies change. # remeber to bump this hash when your dependencies change.
#vendorSha256 = pkgs.lib.fakeSha256; #vendorSha256 = pkgs.lib.fakeSha256;
vendorSha256 = "sha256-n5XcZjTGWlkXawZn7ln5FOdQ23BYbpFf8XcsRuJTUqo="; #vendorHash = pkgs.lib.fakeHash;
vendorHash = "sha256-j3gYTLV+EvGILC1qWiLCPEaSF+XKVwd27pwjckXsT9Q=";
meta = with nixpkgs.legacyPackages.${system}.lib; { meta = with nixpkgs.legacyPackages.${system}.lib; {
description = "Version is a program that automates and simplifies the process of incrementing version numbers for software projects."; description = "Version is a program that automates and simplifies the process of incrementing version numbers for software projects.";
...@@ -56,6 +58,9 @@ ...@@ -56,6 +58,9 @@
}; };
}; };
default = self.packages.${system}.version;
}); });
# Add dependencies that are only needed for development # Add dependencies that are only needed for development
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="accountSettings">
<option name="activeProfile" value="profile:default" />
<option name="activeRegion" value="eu-west-1" />
<option name="recentlyUsedProfiles">
<list>
<option value="profile:default" />
</list>
</option>
<option name="recentlyUsedRegions">
<list>
<option value="eu-west-1" />
</list>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/source.iml" filepath="$PROJECT_DIR$/.idea/source.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="8d3aa146-664b-44b9-8e93-a787f1bd5bc2" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/../Taskfile.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../Taskfile.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../bin/go-compile.sh" beforeDir="false" afterPath="$PROJECT_DIR$/../bin/go-compile.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../devenv.nix" beforeDir="false" afterPath="$PROJECT_DIR$/../devenv.nix" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings">
<execution />
</component>
<component name="GOROOT" url="file:///nix/store/y7abhs9glxfcg7lgcdc8i4ml5wg5ly92-go-1.21.4/share/go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 6
}]]></component>
<component name="ProjectId" id="2aOXlH5e6aZwiqCYL2Bj9xiU1Vm" />
<component name="ProjectViewState">
<option name="flattenModules" value="true" />
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showVisibilityIcons" value="true" />
<option name="sortByType" value="true" />
<option name="sortKey" value="BY_TYPE" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.go.migrated.go.modules.settings": "true",
"go.sdk.automatically.set": "true",
"last_opened_file_path": "/home/volker.schukai/projekte/workspaces/codeserver",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "http.proxy"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>
</component>
</project>
\ No newline at end of file
module gitlab.schukai.com/oss/utilities/version module gitlab.schukai.com/oss/utilities/version
go 1.18 go 1.21
require ( require (
github.com/Masterminds/semver v1.5.0 github.com/Masterminds/semver v1.5.0
github.com/go-git/go-git/v5 v5.10.0 github.com/go-git/go-git/v5 v5.11.0
github.com/jessevdk/go-flags v1.5.0 github.com/jessevdk/go-flags v1.5.0
github.com/tidwall/gjson v1.17.0 github.com/tidwall/gjson v1.17.0
github.com/tidwall/sjson v1.2.5 github.com/tidwall/sjson v1.2.5
...@@ -17,28 +17,27 @@ require ( ...@@ -17,28 +17,27 @@ require (
dario.cat/mergo v1.0.0 // indirect dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect github.com/cloudflare/circl v1.3.7 // indirect
github.com/cloudflare/circl v1.3.6 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
github.com/emirpasic/gods v1.18.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect github.com/sergi/go-diff v1.3.1 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect github.com/skeema/knownhosts v1.2.1 // indirect
github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.15.0 // indirect golang.org/x/crypto v0.17.0 // indirect
golang.org/x/mod v0.14.0 // indirect golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.14.0 // indirect golang.org/x/sys v0.15.0 // indirect
golang.org/x/tools v0.15.0 // indirect golang.org/x/tools v0.16.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect
) )
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16
This diff is collapsed.
package main package main
import ( //var (
"golang.org/x/text/message" // printer *message.Printer
) //)
var (
printer *message.Printer
)
func main() { func main() {
executeCommand() executeCommand()
......
...@@ -73,9 +73,17 @@ func getFromYaml() (string, error) { ...@@ -73,9 +73,17 @@ func getFromYaml() (string, error) {
currentYaml = node currentYaml = node
path, err := yamlpath.NewPath(arguments.Selector) path, err := yamlpath.NewPath(arguments.Selector)
if err != nil {
return "", err
}
results, err := path.Find(&node) results, err := path.Find(&node)
if err != nil {
return "", err
}
if results == nil || len(results) == 0 { // len() for []*gopkg.in/yaml.v3.Node is defined as zero (S1009)
if len(results) == 0 {
return "", notFoundError return "", notFoundError
} }
...@@ -193,12 +201,18 @@ func writeVersionToJson(version string) error { ...@@ -193,12 +201,18 @@ func writeVersionToJson(version string) error {
func writeVersionToYaml(version string) error { func writeVersionToYaml(version string) error {
path, err := yamlpath.NewPath(arguments.Selector) path, err := yamlpath.NewPath(arguments.Selector)
if err != nil {
return err
}
results, err := path.Find(&currentYaml) results, err := path.Find(&currentYaml)
if err != nil {
return err
}
results[0].Value = version results[0].Value = version
//results.Value = version //results.Value = version
fmt.Println(results) //fmt.Println(results)
result, err := yaml.Marshal(&currentYaml) result, err := yaml.Marshal(&currentYaml)
if err != nil { if err != nil {
...@@ -236,7 +250,7 @@ func writeVersionToGit(version string) error { ...@@ -236,7 +250,7 @@ func writeVersionToGit(version string) error {
func writeVersion(version string) error { func writeVersion(version string) error {
if predict == true { if predict {
if nullTerminated { if nullTerminated {
version += string(rune(0)) version += string(rune(0))
fmt.Printf("%s", version) fmt.Printf("%s", version)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment