diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e52c8ca5d..0406457e9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -73,6 +73,15 @@ jobs: with: go-version: ${{ env.GO_VERSION }} cache: true + - uses: actions/cache@v4 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: go-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}-${{ hashFiles('go.sum') }} + restore-keys: | + go-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}- + go-${{ runner.os }}-${{ runner.arch }}- - name: Generate Build Metadata shell: bash run: | @@ -143,6 +152,16 @@ jobs: git show FETCH_HEAD:models.json > internal/registry/models/models.json - name: Fetch tags run: git fetch --force --tags + - uses: actions/cache@v4 + with: + path: | + .freebsd-cache/${{ matrix.goarch }}/go + .freebsd-cache/${{ matrix.goarch }}/gocache + .freebsd-cache/${{ matrix.goarch }}/gomodcache + key: freebsd-${{ matrix.goarch }}-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }} + restore-keys: | + freebsd-${{ matrix.goarch }}-go${{ env.GO_VERSION }}- + freebsd-${{ matrix.goarch }}- - name: Generate Build Metadata run: | echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV @@ -162,10 +181,18 @@ jobs: shell: cpa.sh {0} run: | set -eu - fetch -o /tmp/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.freebsd-${GOARCH}.tar.gz" - rm -rf /tmp/go - tar -C /tmp -xzf /tmp/go.tar.gz - export PATH="/tmp/go/bin:$PATH" + cache_root=".freebsd-cache/${GOARCH}" + go_root="${cache_root}/go" + mkdir -p "${cache_root}/gocache" "${cache_root}/gomodcache" + if [ ! -x "${go_root}/bin/go" ]; then + fetch -o /tmp/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.freebsd-${GOARCH}.tar.gz" + rm -rf "$go_root" + mkdir -p "$cache_root" + tar -C "$cache_root" -xzf /tmp/go.tar.gz + fi + export GOCACHE="$PWD/${cache_root}/gocache" + export GOMODCACHE="$PWD/${cache_root}/gomodcache" + export PATH="$PWD/${go_root}/bin:$PATH" go version archive_dir="dist/${TARGET}/archive"