-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Update Go Workflow and Update to Go 1.18
This workflow runs weekly and updates both the Go version and the Go modules. This will update not just the direct dependencies but also transitive dependencies, which is something Dependabot does not presently do. The Go version is determined by Pipeline Builder. When the Pipeline Builder workflow runs and updates the pipeline, it will update the required Go version in this workflow. The next time this workflow runs, it'll then bump the Go version. This workflow can be directly triggered as well. Signed-off-by: Daniel Mikusa <[email protected]>
- Loading branch information
Daniel Mikusa
committed
Aug 9, 2022
1 parent
5dc43ce
commit d05a581
Showing
4 changed files
with
104 additions
and
2 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
if [ -z "${GO_VERSION:-}" ]; then | ||
echo "No go version set" | ||
exit 1 | ||
fi | ||
|
||
OLD_GO_VERSION=$(grep -P '^go \d\.\d+' go.mod | cut -d ' ' -f 2) | ||
|
||
go mod edit -go="$GO_VERSION" | ||
go mod tidy | ||
go get -u all | ||
go mod tidy | ||
|
||
git add go.mod go.sum | ||
git checkout -- . | ||
|
||
echo "::set-output name=old-go-version::${OLD_GO_VERSION}" | ||
echo "::set-output name=go-version::${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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2018-2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package octo | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/paketo-buildpacks/pipeline-builder/octo/actions" | ||
"github.com/paketo-buildpacks/pipeline-builder/octo/actions/event" | ||
) | ||
|
||
func ContributeUpdateGo(descriptor Descriptor) (Contribution, error) { | ||
w := actions.Workflow{ | ||
Name: "Update Go", | ||
On: map[event.Type]event.Event{ | ||
event.ScheduleType: event.Schedule{{Minute: "0", Hour: "2", DayOfWeek: "1"}}, | ||
event.WorkflowDispatchType: event.WorkflowDispatch{}, | ||
}, | ||
Jobs: map[string]actions.Job{ | ||
"update": { | ||
Name: "Update Go", | ||
RunsOn: []actions.VirtualEnvironment{actions.UbuntuLatest}, | ||
Steps: []actions.Step{ | ||
{ | ||
Uses: "actions/setup-go@v3", | ||
With: map[string]interface{}{"go-version": GoVersion}, | ||
}, | ||
{ | ||
Uses: "actions/checkout@v3", | ||
}, | ||
{ | ||
Id: "update-go", | ||
Name: "Update Go Version", | ||
Run: StatikString("/update-go.sh"), | ||
Env: map[string]string{ | ||
"GO_VERSION": GoVersion, | ||
}, | ||
}, | ||
{ | ||
Uses: "peter-evans/create-pull-request@v4", | ||
With: map[string]interface{}{ | ||
"token": descriptor.GitHub.Token, | ||
"author": fmt.Sprintf("%[1]s <%[1][email protected]>", descriptor.GitHub.Username), | ||
"commit-message": `Bump Go from ${{ steps.update-go.outputs.old-go-version }} to ${{ steps.update-go.outputs.go-version }} | ||
Bumps Go from ${{ steps.update-go.outputs.old-go-version }} to ${{ steps.update-go.outputs.go-version }}.`, | ||
"signoff": true, | ||
"branch": "update/go", | ||
"delete-branch": true, | ||
"title": "Bump Go from ${{ steps.update-go.outputs.old-version }} to ${{ steps.update-go.outputs.new-version }}", | ||
"body": "Bumps Go from `${{ steps.update-go.outputs.old-version }}` to `${{ steps.update-go.outputs.new-version }}`.\n\n<details>\n<summary>Release Notes</summary>\n${{ steps.pipeline.outputs.release-notes }}\n</details>", | ||
"labels": "semver:minor, type:task", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
return NewActionContribution(w) | ||
} |