├── .gitignore ├── go.mod ├── .github ├── dependabot.yml └── workflows │ ├── cleanup.yml │ └── build.yml ├── Dockerfile ├── Makefile ├── LICENSE ├── tipper.go └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.tar.gz 2 | *.txt 3 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/AlekSi/golang-tip 2 | 3 | go 1.24 4 | 5 | toolchain go1.24.3 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: "docker" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | day: "sunday" 9 | time: "02:48" 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | day: "sunday" 15 | time: "02:48" 16 | -------------------------------------------------------------------------------- /.github/workflows/cleanup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Cleanup 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events 7 | # > Note: The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. 8 | # > High load times include the start of every hour. To decrease the chance of delay, schedule your workflow to run at a different time of the hour. 9 | - cron: "48 5 * * *" 10 | 11 | jobs: 12 | docker: 13 | name: Docker 14 | timeout-minutes: 10 15 | 16 | runs-on: ubuntu-24.04 17 | 18 | steps: 19 | - name: Delete old images 20 | uses: actions/delete-package-versions@v5 21 | with: 22 | package-name: golang-tip 23 | package-type: container 24 | min-versions-to-keep: 365 25 | delete-only-untagged-versions: true 26 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1 2 | 3 | ARG GO_BRANCH 4 | 5 | 6 | FROM --platform=$BUILDPLATFORM golang:1.24.3 AS prepare 7 | 8 | RUN git clone https://go.googlesource.com/go /tmp/golang-tip 9 | 10 | 11 | FROM golang:1.24.3 12 | 13 | ARG GO_BRANCH 14 | 15 | ENV GOLANG_VERSION=${GO_BRANCH} 16 | 17 | COPY --from=prepare /tmp/golang-tip /tmp/golang-tip 18 | 19 | RUN < Note: The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. 7 | # > High load times include the start of every hour. To decrease the chance of delay, schedule your workflow to run at a different time of the hour. 8 | - cron: "48 2 * * *" 9 | # For weekly autoreleases 10 | # TODO https://github.com/AlekSi/golang-tip/issues/5 11 | # - cron: '48 1 * * 0' 12 | push: 13 | branches: 14 | - main 15 | pull_request: 16 | paths-ignore: ["**.md"] 17 | 18 | jobs: 19 | docker: 20 | name: Docker (${{ matrix.branch }}) 21 | timeout-minutes: 60 22 | 23 | strategy: 24 | fail-fast: false 25 | matrix: 26 | os: 27 | - ubuntu-24.04 28 | branch: 29 | - master 30 | - release-branch.go1.24 31 | - release-branch.go1.23 32 | 33 | runs-on: ${{ matrix.os }} 34 | 35 | env: 36 | GO_BRANCH: ${{ matrix.branch }} 37 | 38 | steps: 39 | - name: Checkout 40 | uses: actions/checkout@v4 41 | 42 | - name: Setup QEMU 43 | uses: docker/setup-qemu-action@v3 44 | 45 | - name: Login into Docker registries 46 | if: github.event_name != 'pull_request' 47 | run: | 48 | docker login --username aleksi --password ${{ secrets.DOCKERHUB_TOKEN }} 49 | docker login ghcr.io --username aleksi --password ${{ secrets.GITHUB_TOKEN }} 50 | 51 | - name: Start BuildKit builder 52 | run: make docker-up 53 | 54 | - name: Build Docker images for PR 55 | if: github.event_name == 'pull_request' 56 | run: make docker-build 57 | 58 | - name: Build Docker images for Docker Hub 59 | if: github.event_name != 'pull_request' 60 | run: make docker-build 61 | env: 62 | DOCKER_PLATFORM: linux/amd64,linux/arm64 63 | DOCKER_OUTPUT: type=image,push=true,annotation-index.org.opencontainers.image.description="Daily builds of active Go development branches (branch ${{ env.GO_BRANCH }})" 64 | DOCKER_TAG: aleksi/golang-tip:${{ env.GO_BRANCH }} 65 | 66 | - name: Build Docker images for ghcr.io 67 | if: github.event_name != 'pull_request' 68 | run: make docker-build 69 | env: 70 | DOCKER_PLATFORM: linux/amd64,linux/arm64 71 | DOCKER_OUTPUT: type=image,push=true,annotation-index.org.opencontainers.image.description="Daily builds of active Go development branches (branch ${{ env.GO_BRANCH }})" 72 | DOCKER_TAG: ghcr.io/aleksi/golang-tip:${{ env.GO_BRANCH }} 73 | 74 | # skip push for PRs 75 | # move to `publish` job 76 | # TODO https://github.com/AlekSi/golang-tip/issues/8 77 | 78 | targz: 79 | name: TarGz (${{ matrix.branch }}, ${{ matrix.os }}, ${{ matrix.goroot }}) 80 | timeout-minutes: 10 81 | 82 | strategy: 83 | fail-fast: false 84 | matrix: 85 | os: 86 | - ubuntu-24.04 87 | - macos-13 88 | - macos-15 89 | branch: 90 | - master 91 | - release-branch.go1.24 92 | - release-branch.go1.23 93 | goroot: 94 | - /usr/local/go 95 | - /tmp/golang-tip 96 | 97 | runs-on: ${{ matrix.os }} 98 | 99 | env: 100 | GO_BRANCH: ${{ matrix.branch }} 101 | GOROOT_FINAL: ${{ matrix.goroot }} 102 | 103 | steps: 104 | - name: Checkout 105 | uses: actions/checkout@v4 106 | 107 | - name: Setup Go 108 | uses: actions/setup-go@v5 109 | with: 110 | go-version-file: go.mod 111 | cache: false 112 | 113 | - name: Build .tar.gz file 114 | run: make targz-build 115 | 116 | - name: Set artifact suffix 117 | if: startsWith(env.GOROOT_FINAL, '/tmp/') 118 | run: | 119 | echo ARTIFACT_SUFFIX=.tmp >> $GITHUB_ENV 120 | 121 | - name: Set artifact name 122 | run: | 123 | echo ARTIFACT_NAME=${{ env.GO_BRANCH }}.$(go env GOOS)-$(go env GOARCH)${{ env.ARTIFACT_SUFFIX }} >> $GITHUB_ENV 124 | 125 | - name: Rename artifact 126 | run: mv golang-tip.tar.gz ${{ env.ARTIFACT_NAME }}.tar.gz 127 | 128 | - name: Upload artifact 129 | uses: actions/upload-artifact@v4 130 | with: 131 | name: ${{ env.ARTIFACT_NAME }} 132 | path: ${{ env.ARTIFACT_NAME }}.tar.gz 133 | if-no-files-found: error 134 | 135 | publish: 136 | name: Publish 137 | needs: [docker, targz] 138 | timeout-minutes: 10 139 | runs-on: ubuntu-24.04 140 | if: github.actor != 'dependabot[bot]' 141 | 142 | steps: 143 | - name: Checkout 144 | uses: actions/checkout@v4 145 | 146 | - name: Download artifacts 147 | uses: actions/download-artifact@v4 148 | 149 | - name: Prepare files 150 | run: | 151 | go version 152 | go run tipper.go all 153 | 154 | - name: Publish artifacts 155 | if: github.event_name != 'pull_request' 156 | uses: marvinpinto/action-automatic-releases@v1.2.1 157 | with: 158 | repo_token: ${{ secrets.GITHUB_TOKEN }} 159 | automatic_release_tag: tip 160 | title: tip 161 | prerelease: false 162 | draft: false 163 | files: | 164 | **.tar.gz 165 | *.txt 166 | 167 | - name: Publish PR artifacts 168 | if: github.event_name == 'pull_request' 169 | uses: marvinpinto/action-automatic-releases@v1.2.1 170 | with: 171 | repo_token: ${{ secrets.GITHUB_TOKEN }} 172 | automatic_release_tag: test 173 | title: Test release by pull request; do not use 174 | prerelease: true 175 | draft: false 176 | files: | 177 | **.tar.gz 178 | *.txt 179 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repo is semi-deprecated in favor of new [official `golang:XXX-tip` images](https://hub.docker.com/_/golang) 2 | that are rebuilt weekly but support more architectures. 3 | 4 | --- 5 | 6 | # golang-tip 7 | 8 | [![Build](https://github.com/AlekSi/golang-tip/actions/workflows/build.yml/badge.svg?branch=main&event=schedule)](https://github.com/AlekSi/golang-tip/actions/workflows/build.yml) 9 | [![Go Report Card](https://goreportcard.com/badge/github.com/AlekSi/golang-tip)](https://goreportcard.com/report/github.com/AlekSi/golang-tip) 10 | 11 | Daily builds of [active Go development branches](https://github.com/golang/go/branches/active). 12 | Available as: 13 | * Docker images (based on [Go "Official Image"](https://github.com/docker-library/golang)) 14 | on both [Docker Hub](https://hub.docker.com/r/aleksi/golang-tip) 15 | and [GitHub Container Registry](https://github.com/users/AlekSi/packages/container/package/golang-tip) 16 | * [.tar.gz files](https://github.com/AlekSi/golang-tip/releases/tag/tip) 17 | 18 | They may be used on CI/CD to avoid rebuilding Go from the source code every time, saving time and resources. They may also be used for local development. 19 | 20 | 21 | # Quickstart 22 | 23 | Examples for `master` / tip branch: 24 | 25 | ```sh 26 | docker pull aleksi/golang-tip:master 27 | # or 28 | docker pull ghcr.io/aleksi/golang-tip:master 29 | 30 | # then use it as an official Go Docker image 31 | ``` 32 | 33 | ```sh 34 | # for Linux 35 | curl -o master.tmp.tar.gz -L https://github.com/AlekSi/golang-tip/releases/download/tip/master.linux-amd64.tmp.tar.gz 36 | 37 | # for macOS 38 | curl -o master.tmp.tar.gz -L https://github.com/AlekSi/golang-tip/releases/download/tip/master.darwin-amd64.tmp.tar.gz 39 | 40 | # for both 41 | rm -rf /tmp/golang-tip && tar -C /tmp -xzf master.tmp.tar.gz 42 | /tmp/golang-tip/bin/go env 43 | ``` 44 | 45 | ## Using golang-tip in GitHub Actions 46 | 47 | Examples for using golang-tip in a GitHub Action. 48 | 49 | ### .tar.gz 50 | 51 | > This example shows how to use golang-tip's .tar.gz release format 52 | within a GitHub Actions runner. We first purge an existing Go installation. 53 | If you are looking to save on Actions minutes, this workflow takes 54 | less than half the time to run as the container example below. 55 | 56 | ```yaml 57 | # Remove existing Go installation, install golang-tip from latest .tar.gz 58 | # More .tar.gz releases can be found here: https://github.com/AlekSi/golang-tip/releases/tag/tip 59 | 60 | # action.yml 61 | --- 62 | name: Go unit tests with golang-tip 63 | on: 64 | pull_request: 65 | jobs: 66 | test-my-app-targz: 67 | name: test my golang app using golang-tip .tar.gz release 68 | runs-on: ubuntu-latest 69 | steps: 70 | - name: Remove existing go installation from Actions runner 71 | run: | 72 | sudo rm -fr /opt/hostedtoolcache/go /usr/local/go /usr/bin/go /bin/go 73 | - name: Install latest golang-tip on Actions runner 74 | run: | 75 | curl -o go.tar.gz -L \ 76 | https://github.com/AlekSi/golang-tip/releases/download/tip/master.linux-amd64.tar.gz 77 | sudo tar -C /usr/local -xzf go.tar.gz 78 | sudo ln -s /usr/local/go/bin/* /usr/local/bin/ 79 | - uses: actions/checkout@v2 80 | - name: run tests 81 | run: go test ./... 82 | ``` 83 | 84 | ### Container image 85 | 86 | > This example shows how you can use golang-tip's prebuilt container image 87 | directly within your GitHub Action Workflow. All `steps` are executed within 88 | the container image at `ghcr.io/aleksi/golang-tip:master` for the `test-my-app` 89 | Job. 90 | 91 | ```yaml 92 | # Run your Job within latest golang-tip built container. 93 | # Use head of golang-tip aka "master" or other available image tags here: 94 | # https://github.com/AlekSi/golang-tip/pkgs/container/golang-tip 95 | 96 | # action.yml 97 | --- 98 | name: Go unit tests with golang-tip 99 | on: 100 | pull_request: 101 | jobs: 102 | test-my-app-oci: 103 | name: test my golang app using golang-tip container release 104 | runs-on: ubuntu-latest 105 | container: 106 | image: ghcr.io/aleksi/golang-tip:master 107 | steps: 108 | - uses: actions/checkout@v2 109 | - name: run tests 110 | run: go test ./... 111 | ``` 112 | 113 | # Branches 114 | 115 | Currently built branches (see [here](https://github.com/AlekSi/golang-tip/blob/main/.github/workflows/build.yml)): 116 | * `master` a.k.a tip, the next Go version. 117 | * `release-branch.go1.24` 118 | * `release-branch.go1.23` 119 | 120 | # Docker 121 | 122 | Docker images are based on the latest stable Go image. The development version completely replaces stable Go in `/usr/local/go`. 123 | `GOLANG_VERSION` environment variable is set to the branch name. 124 | 125 | ```dockerfile 126 | FROM aleksi/golang-tip:master 127 | ``` 128 | 129 | or 130 | 131 | ```dockerfile 132 | FROM ghcr.io/aleksi/golang-tip:master 133 | ``` 134 | 135 | 136 | # .tar.gz 137 | 138 | `.tar.gz` files are provided in two variants. The main one behaves like [the official Go release](https://golang.org/doc/install) - 139 | it is expected to be unpacked into `/usr/local` as `/usr/local/go`: 140 | 141 | ```sh 142 | rm -rf /usr/local/go && tar -C /usr/local -xzf master.linux-amd64.tar.gz 143 | ``` 144 | 145 | The variant with `.tmp` in the file name is expected to be unpacked into `/tmp` as `/tmp/golang-tip` (that's the value of [GOROOT_FINAL](https://golang.org/doc/install/source#environment) set during compilation): 146 | 147 | ```sh 148 | rm -rf /tmp/golang-tip && tar -C /tmp -xzf master.linux-amd64.tmp.tar.gz 149 | ``` 150 | 151 | That allows that version to co-exist with other versions of Go and be installed without additional privileges. 152 | 153 | 154 | # Credits 155 | 156 | Made by Alexey Palazhchenko. 157 | 158 | Inspired by [go-tip by Craig Peterson](https://github.com/captncraig/go-tip). 159 | 160 | 161 | # Contributing 162 | 163 | Pull requests that add other branches, base Docker images, OSes, and CPU architectures are welcome. 164 | --------------------------------------------------------------------------------