Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/go 1.30.8 #41

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/update-go-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Update Golang version
run-name: ${{ github.actor }} has started Golang version update
on:
push:
branches:
- 'update/go_*'
- 'main'
jobs:
update-go-version:
runs-on: ubuntu-latest
outputs:
new-go-version: ${{ steps.get-version-number.outputs.new-go-version }}
new-go-major-version: ${{ steps.get-version-number.outputs.new-go-major-version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get old and new go versions
id: get-go-version
run: |
OLD_GO_VERSION=$(grep -F "go-version: " .github/workflows/build-and-test.yaml)
OLD_GO_VERSION=$(echo $OLD_GO_VERSION | sed -e 's/go-version: //g')
OLD_GO_MAJOR_VERSION=${OLD_GO_VERSION%.*}

NEW_GO_VERSION=$(echo "${{ github.ref }}" | sed 's/refs\/heads\/update\/go_//g')
NEW_GO_MAJOR_VERSION=${NEW_GO_VERSION%.*}

echo "Old go version $OLD_GO_VERSION"
echo "Old go major version $OLD_GO_MAJOR_VERSION"

echo "New go version $NEW_GO_VERSION"
echo "New go major version $NEW_GO_MAJOR_VERSION"

echo "old-go-version=${OLD_GO_VERSION}" >> "$GITHUB_OUTPUT"
echo "old-go-major-version=${OLD_GO_MAJOR_VERSION}" >> "$GITHUB_OUTPUT"

echo "new-go-version=${NEW_GO_VERSION}" >> "$GITHUB_OUTPUT"
echo "new-go-major-version=${NEW_GO_MAJOR_VERSION}" >> "$GITHUB_OUTPUT"

- name: Update Go version in code to ${{ steps.get-version-number.outputs.new-go-version }}
run: |
find . -name '*.yaml' -exec sed -i -e 's/${{steps.get-go-version.outputs.old-go-version}}/${{steps.get-go-version.outputs.new-go-version}}/g' {} +;
find . -name '*.yaml' -exec sed -i -e 's/${{steps.get-go-version.outputs.old-go-major-version}}/${{steps.get-go-version.outputs.new-go-major-version}}/g' {} +;

- name: Create & push commit
run: |
git config --global user.email "[email protected]"
git config --global user.name "NSMBot"
git commit -s -a -m "Update Go version to ${{ steps.get-version-number.outputs.new-go-version }}"
git push
10 changes: 10 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

string="refs/heads/update/go_1.30.8"
f=${string#refs/heads/update/go_}

echo $f

OLD_GO_VERSION=$(grep -F "go-version: " .github/workflows/build-and-test.yaml)
OLD_GO_VERSION=$(echo $OLD_GO_VERSION | sed -e 's/go-version: //g')

echo $OLD_GO_VERSION
Loading