-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Add bump go script * ci: Decrease matrix
- Loading branch information
1 parent
c3a5f3f
commit d28d2ea
Showing
5 changed files
with
95 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ jobs: | |
# Learn more about CodeQL language support at https://git.io/codeql-language-support | ||
language: [ 'go' ] | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
@@ -45,7 +45,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
go version | ||
shell: bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ jobs: | |
max-parallel: 3 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Build | ||
steps: | ||
|
@@ -55,7 +55,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- run: | | ||
go version | ||
|
@@ -90,7 +90,7 @@ jobs: | |
max-parallel: 2 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Run Tests | ||
steps: | ||
|
@@ -102,7 +102,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- run: | | ||
go version | ||
|
@@ -137,7 +137,7 @@ jobs: | |
max-parallel: 2 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Run linters | ||
steps: | ||
|
@@ -149,7 +149,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
go version | ||
shell: bash | ||
|
@@ -189,7 +189,7 @@ jobs: | |
max-parallel: 1 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Quality reports | ||
steps: | ||
|
@@ -201,7 +201,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
go version | ||
shell: bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
max-parallel: 2 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Build | ||
steps: | ||
|
@@ -26,7 +26,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- run: | | ||
go version | ||
|
@@ -60,7 +60,7 @@ jobs: | |
max-parallel: 2 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Regression tests | ||
steps: | ||
|
@@ -72,7 +72,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- run: | | ||
go version | ||
|
@@ -109,7 +109,7 @@ jobs: | |
max-parallel: 1 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Lint | ||
steps: | ||
|
@@ -121,7 +121,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- run: | | ||
go version | ||
|
@@ -162,7 +162,7 @@ jobs: | |
max-parallel: 1 | ||
matrix: | ||
os: [ 'ubuntu-22.04' ] | ||
go: [ '1.21' ] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.os }} | ||
name: Release | ||
steps: | ||
|
@@ -174,7 +174,7 @@ jobs: | |
- name: Set up go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ matrix.go }} | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- run: | | ||
go version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |