Skip to content

Commit d66690e

Browse files
V3 - Initial Cut of Modernized Go version (#479)
* Goenv go migration * GOENV_AUTO_INSTALL * Windows support, maybe * Don't commit this * Update workflows * Remove old tests * Remove plugins * Powershell makes * Minor cleanup * Cleanup * Remove legacy code * Fix 0 args output * Near parity * Win compat * Don't remove go in workflows * Swap local goenv script for testing * More verbose caching/version list strategy * Prefer toolchain version over go version * List tests * Consistent stdio * Swap go script * Arg validation * Expand path, tilde fixes * Minor fixes
0 parents  commit d66690e

385 files changed

Lines changed: 135508 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
./versions
2+
./cache

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
indent_size = 2
7+
indent_style = space
8+
9+
[Makefile]
10+
indent_style = tab

.gitattributes

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# GitHub "Languages" statistics only consider file extensions, not contents
2+
# https://github.com/github-linguist/linguist/blob/master/docs/overrides.md
3+
# Reclassify files as Shell for proper statistics (instead of "Roff")
4+
libexec/* linguist-language=Shell
5+
src/shobj-conf/* linguist-language=Shell
6+
test/libexec/* linguist-language=Shell
7+
8+
# Line ending normalization for cross-platform compatibility
9+
# Ensure consistent line endings across Windows, macOS, and Linux
10+
11+
# Shell scripts always use LF (required for Unix shells)
12+
*.sh text eol=lf
13+
*.bash text eol=lf
14+
*.zsh text eol=lf
15+
*.fish text eol=lf
16+
17+
# Windows batch and PowerShell files use CRLF
18+
*.bat text eol=crlf
19+
*.cmd text eol=crlf
20+
*.ps1 text eol=crlf
21+
22+
# Go source files use LF
23+
*.go text eol=lf
24+
*.mod text eol=lf
25+
*.sum text eol=lf
26+
27+
# Documentation and config files use LF
28+
*.md text eol=lf
29+
*.txt text eol=lf
30+
*.json text eol=lf
31+
*.yaml text eol=lf
32+
*.yml text eol=lf
33+
*.toml text eol=lf
34+
Makefile text eol=lf
35+
36+
# Binary files
37+
*.exe binary
38+
*.dll binary
39+
*.so binary
40+
*.dylib binary
41+
*.a binary
42+
*.tar.gz binary
43+
*.zip binary
44+

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## PRs will automatically tag the following users for Review
2+
3+
* @syndbg @ChronosMasterOfAllTime @reneleonhardt

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "gomod"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
open-pull-requests-limit: 5

.github/release-drafter-v3.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name-template: '$RESOLVED_VERSION'
2+
tag-template: '$RESOLVED_VERSION'
3+
version-template: '3.$MINOR.$PATCH'
4+
filter-by-commitish: true
5+
commitish: v3
6+
categories:
7+
- title: '🚀 Features'
8+
labels:
9+
- 'feature'
10+
- 'enhancement'
11+
- title: '🐛 Bug Fixes'
12+
labels:
13+
- 'fix'
14+
- 'bugfix'
15+
- 'bug'
16+
- title: '🧰 Maintenance'
17+
labels:
18+
- 'chore'
19+
- 'maintenance'
20+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
21+
change-title-escapes: '\<*_&'
22+
version-resolver:
23+
minor:
24+
labels:
25+
- 'minor-release'
26+
patch:
27+
labels:
28+
- 'patch-release'
29+
default: patch
30+
template: |
31+
## Changes since $PREVIOUS_TAG
32+
33+
$CHANGES

.github/release-drafter.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name-template: "$RESOLVED_VERSION"
2+
tag-template: "$RESOLVED_VERSION"
3+
version-template: '2.$MINOR.$PATCH'
4+
filter-by-commitish: true
5+
commitish: master
6+
categories:
7+
- title: "🚀 Features"
8+
labels:
9+
- "feature"
10+
- "enhancement"
11+
- title: "🎉 New Golang Versions"
12+
labels:
13+
- "go-version"
14+
- title: "🪲 Bug Fixes"
15+
labels:
16+
- "fix"
17+
- "bugfix"
18+
- "bug"
19+
- title: "🧰 Maintenance"
20+
label: "chore"
21+
- title: "🏗️ Build System"
22+
labels:
23+
- "build"
24+
- "build-system"
25+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
26+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
27+
autolabeler:
28+
- label: "chore"
29+
files:
30+
- "*.md"
31+
- ".github/*"
32+
branch:
33+
- '/docs{0,1}\/.+/'
34+
title:
35+
- "/chore/i"
36+
- label: "bug"
37+
branch:
38+
- '/fix\/.+/'
39+
title:
40+
- "/fix/i"
41+
- label: "enhancement"
42+
branch:
43+
- '/feature\/.+/i'
44+
- label: "build-system"
45+
files:
46+
- "scripts/build-tool/*"
47+
- "Makefile"
48+
- "build.*"
49+
- ".goreleaser.yml"
50+
title:
51+
- "/build/i"
52+
- label: "go-version"
53+
branch:
54+
- '/feature\/.+/i'
55+
files:
56+
- "internal/version/embedded_versions.go"
57+
- "scripts/generate_embedded_versions/*"
58+
body:
59+
- '/(add|support) go(lang)? [0-9]+\.[0-9]+(\.[0-9]+)?/i'
60+
version-resolver:
61+
major:
62+
labels:
63+
- "major-release"
64+
minor:
65+
labels:
66+
- "minor-release"
67+
patch:
68+
labels:
69+
- "patch-release"
70+
default: patch
71+
template: |
72+
## Changes since $PREVIOUS_TAG
73+
74+
$CHANGES
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash -e
2+
3+
if [[ $DEBUG == "true" ]]; then
4+
echo "DEBUG is enabled"
5+
set -x # Print commands and their arguments as they are executed
6+
fi
7+
8+
APP_VERSION_FILE="APP_VERSION"
9+
10+
# This script is used to update the version of the app.
11+
12+
# Get the latest draft version from the GitHub Releases
13+
# and take into accoutn that the most recent version is the latest version,
14+
# while the second most recent version is the second entry.
15+
# ❯ gh release list -L 5
16+
# TITLE TYPE TAG NAME PUBLISHED
17+
# 2.2.27 Latest 2.2.27 about 5 days ago
18+
# 2.2.28 Draft 2.2.28 about 1 month ago
19+
# 2.2.26 2.2.26 about 1 month ago
20+
# 2.2.25 2.2.25 about 2 months ago
21+
# 2.2.24 2.2.24 about 2 months ago
22+
LATEST_DRAFT_VERSION=$(gh release list -L 20 | awk -F '\t' '{if ($2 == "Draft" && match($3, "^[0-9]+\\.[0-9]+\\.[0-9]+")) {print $3; exit}}')
23+
LATEST_VERSION=$(gh release view --json tagName -q .tagName)
24+
25+
if [[ $LATEST_DRAFT_VERSION == $LATEST_VERSION ]]; then
26+
echo "latest draft version ($LATEST_DRAFT_VERSION) matches latest version ($LATEST_VERSION)"
27+
exit 0
28+
elif [[ $LATEST_DRAFT_VERSION == $(cat $APP_VERSION_FILE) ]]; then
29+
echo "latest draft version ($LATEST_DRAFT_VERSION) matches current version in $APP_VERSION_FILE"
30+
exit 0
31+
fi
32+
33+
if [[ -n $GITHUB_ACTOR ]]; then
34+
git config --global user.name "${GITHUB_ACTOR}"
35+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
36+
fi
37+
38+
BRANCH_NAME_PREFIX="update-app-version"
39+
40+
BRANCH_NAME="$BRANCH_NAME_PREFIX-$LATEST_DRAFT_VERSION"
41+
42+
EXISTS=$(git branch -r -l 'origin*' | sed -E -e 's/^[^\/]+\///g' -e 's/HEAD.+//' | grep "$BRANCH_NAME" || echo "false")
43+
44+
if [[ -n $EXISTS ]] && [[ $EXISTS != "false" ]]; then
45+
echo "A PR already exists on branch $BRANCH_NAME for App Version update: $LATET_DRAFT_VERSION"
46+
exit 0
47+
fi
48+
49+
echo "checking out new Git branch $BRANCH_NAME..."
50+
51+
git switch -c $BRANCH_NAME master
52+
53+
printf " done\n"
54+
55+
echo "Updating $APP_VERSION_FILE..."
56+
57+
echo $LATEST_DRAFT_VERSION >$APP_VERSION_FILE
58+
59+
echo "Committing changes..."
60+
61+
COMMIT_MSG="Update $APP_VERSION_FILE to $LATEST_DRAFT_VERSION"
62+
63+
git add $APP_VERSION_FILE
64+
65+
git commit -m "$COMMIT_MSG"
66+
67+
echo "Pushing to origin..."
68+
69+
git push -u origin $BRANCH_NAME
70+
71+
echo "Creating Pull Request..."
72+
73+
printf "This updates the App Version to $LATEST_DRAFT_VERSION" | gh pr create -R go-nv/goenv -B master \
74+
-t "$COMMIT_MSG" \
75+
-F -
76+
77+
echo 'All done!'

.github/workflows/pr_checks.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- "*"
8+
pull_request:
9+
branches:
10+
- "*"
11+
merge_group:
12+
jobs:
13+
build:
14+
strategy:
15+
matrix:
16+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
17+
goenv_native_ext: ["", "1"]
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v5
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: "stable"
25+
- name: Build goenv
26+
shell: bash
27+
run: make build
28+
- name: Run Unit Tests
29+
shell: bash
30+
run: |
31+
echo "Running tests with GOENV_NATIVE_EXT=${{ matrix.goenv_native_ext }}"
32+
make test 2>&1 | tee test_output.log
33+
test_exit_code=${PIPESTATUS[0]}
34+
if [ $test_exit_code -ne 0 ]; then
35+
echo "Tests failed with exit code $test_exit_code"
36+
echo "=== First 100 lines of output ==="
37+
head -100 test_output.log
38+
echo "=== Last 100 lines of output ==="
39+
tail -100 test_output.log
40+
echo "=== Searching for FAIL ==="
41+
grep -B 5 -A 5 "FAIL" test_output.log || true
42+
exit $test_exit_code
43+
fi
44+
env:
45+
GOENV_NATIVE_EXT: ${{ matrix.goenv_native_ext }}

.github/workflows/pre_release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Pre Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
debug:
7+
description: "Debug mode"
8+
type: boolean
9+
required: false
10+
default: false
11+
12+
jobs:
13+
do_prerelease:
14+
if: github.repository_owner == 'go-nv'
15+
strategy:
16+
matrix:
17+
os: ["ubuntu-latest"]
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v5
21+
with:
22+
fetch-depth: 0
23+
ref: master
24+
token: ${{ secrets.GH_TOKEN }}
25+
- name: Install JQ
26+
run: sudo apt install jq
27+
- name: Update App Version
28+
run: |
29+
if [[ "${{ github.event.inputs.debug }}" == "true" ]]; then
30+
echo "Debug mode enabled"
31+
./.github/scripts/update_app_version.sh 2>&1 | tee -a debug.log
32+
cat debug.log
33+
else
34+
./.github/scripts/update_app_version.sh
35+
fi
36+
env:
37+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
38+
DEBUG: ${{ github.event.inputs.debug }}

0 commit comments

Comments
 (0)