Skip to content

Commit

Permalink
chore: Bump go version to 1.22 (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
obalunenko committed Feb 20, 2024
1 parent 4bb60d7 commit 23031b0
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
matrix:
language: [ 'go' ]
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

Expand All @@ -45,7 +45,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
max-parallel: 3
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Build
steps:
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Run Tests
steps:
Expand All @@ -101,7 +101,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Run linters
steps:
Expand All @@ -148,7 +148,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Quality reports
steps:
Expand All @@ -200,7 +200,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}
- run: |
go version
shell: bash
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Regression tests
steps:
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Lint
steps:
Expand All @@ -74,7 +74,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.21' ]
go-version: [1.22.x]
runs-on: ${{ matrix.os }}
name: Release
steps:
Expand All @@ -127,7 +127,7 @@ jobs:
- name: Set up go
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ matrix.go }}
go-version: ${{ matrix.go-version }}

- run: |
go version
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ BIN_DIR=./bin
SHELL := env VERSION=$(VERSION) $(SHELL)
VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))

GOVERSION:=1.22

APP_NAME?=logger
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)

Expand Down Expand Up @@ -135,4 +137,9 @@ new-version: vet test-regression build
./scripts/release/new-version.sh
.PHONY: new-release

bump-go-version:
./scripts/bump-go.sh $(GOVERSION)
.PHONY: bump-go-version


.DEFAULT_GOAL := help
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/obalunenko/logger

go 1.21
go 1.22
71 changes: 71 additions & 0 deletions scripts/bump-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

readonly CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly ROOT_DIR="$(dirname "$CURRENT_DIR")"
readonly GO_MOD_FILE="${ROOT_DIR}/go.mod"

function main() {
echo "Updating Go version:"

local currentGoVersion="$(extractCurrentVersion)"
echo " - Current: ${currentGoVersion}"
local escapedCurrentGoVersion="$(echo "${currentGoVersion}" | sed 's/\./\\./g')"

local goVersion="${1}"
local escapedGoVersion="$(echo "${goVersion}" | sed 's/\./\\./g')"
echo " - New: ${goVersion}"

# bump mod files in all the modules
for modFile in $(find "${ROOT_DIR}" -name "go.mod" -not -path "${ROOT_DIR}/vendor/*" -not -path "${ROOT_DIR}/.git/*"); do
bumpModFile "${modFile}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done

# bump markdown files
for f in $(find "${ROOT_DIR}" -name "*.md"); do
bumpGolangDockerImages "${f}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done

# bump github action workflows
for f in $(find "${ROOT_DIR}/.github/workflows" -name "*.yml"); do
bumpCIMatrix "${f}" "${escapedCurrentGoVersion}" "${escapedGoVersion}"
done
}

# it will replace the 'go-version: [${oldGoVersion}, 1.x]' with 'go-version: [${newGoVersion}, 1.x]' in the given file
function bumpCIMatrix() {
local file="${1}"
local oldGoVersion="${2}"
local newGoVersion="${3}"

sed "s/go-version: \[${oldGoVersion}/go-version: \[${newGoVersion}/g" ${file} > ${file}.tmp
mv ${file}.tmp ${file}
}

# it will replace the 'golang:${oldGoVersion}' with 'golang:${newGoVersion}' in the given file
function bumpGolangDockerImages() {
local file="${1}"
local oldGoVersion="${2}"
local newGoVersion="${3}"

sed "s/golang:${oldGoVersion}/golang:${newGoVersion}/g" ${file} > ${file}.tmp
mv ${file}.tmp ${file}

}

# it will replace the 'go ${oldGoVersion}' with 'go ${newGoVersion}' in the given go.mod file
function bumpModFile() {
local goModFile="${1}"
local oldGoVersion="${2}"
local newGoVersion="${3}"

sed "s/^go ${oldGoVersion}/go ${newGoVersion}/g" ${goModFile} > ${goModFile}.tmp
mv ${goModFile}.tmp ${goModFile}

}

# This function reads the reaper.go file and extracts the current version.
function extractCurrentVersion() {
cat "${GO_MOD_FILE}" | grep '^go .*' | sed 's/^go //g' | head -n 1
}

main "$@"

0 comments on commit 23031b0

Please sign in to comment.