History

chore(build): add caching for Go dependencies and FreeBSD-specific artifacts in release workflow

Luis Pater committed 5 months ago

Commit c75fb2c1 parent 3dedf471 file · +31 −4Browse files

Unified · Split

.github/workflows/release.yaml+31−4
@@ -73,6 +73,15 @@ jobs: · 72 unmodified lines
7373 with:
7474 go-version: ${{ env.GO_VERSION }}
7575 cache: true
76+ - uses: actions/cache@v4
77+ with:
78+ path: |
79+ ~/.cache/go-build
80+ ~/go/pkg/mod
81+ key: go-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}-${{ hashFiles('go.sum') }}
82+ restore-keys: |
83+ go-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}-
84+ go-${{ runner.os }}-${{ runner.arch }}-
7685 - name: Generate Build Metadata
7786 shell: bash
7887 run: |
@@ -143,6 +152,16 @@ jobs: · 64 unmodified lines
143152 git show FETCH_HEAD:models.json > internal/registry/models/models.json
144153 - name: Fetch tags
145154 run: git fetch --force --tags
155+ - uses: actions/cache@v4
156+ with:
157+ path: |
158+ .freebsd-cache/${{ matrix.goarch }}/go
159+ .freebsd-cache/${{ matrix.goarch }}/gocache
160+ .freebsd-cache/${{ matrix.goarch }}/gomodcache
161+ key: freebsd-${{ matrix.goarch }}-go${{ env.GO_VERSION }}-${{ hashFiles('go.sum') }}
162+ restore-keys: |
163+ freebsd-${{ matrix.goarch }}-go${{ env.GO_VERSION }}-
164+ freebsd-${{ matrix.goarch }}-
146165 - name: Generate Build Metadata
147166 run: |
148167 echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
@@ -162,10 +181,18 @@ jobs: · 13 unmodified lines
162181 shell: cpa.sh {0}
163182 run: |
164183 set -eu
165− fetch -o /tmp/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.freebsd-${GOARCH}.tar.gz"
166− rm -rf /tmp/go
167− tar -C /tmp -xzf /tmp/go.tar.gz
168− export PATH="/tmp/go/bin:$PATH"
184+ cache_root=".freebsd-cache/${GOARCH}"
185+ go_root="${cache_root}/go"
186+ mkdir -p "${cache_root}/gocache" "${cache_root}/gomodcache"
187+ if [ ! -x "${go_root}/bin/go" ]; then
188+ fetch -o /tmp/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.freebsd-${GOARCH}.tar.gz"
189+ rm -rf "$go_root"
190+ mkdir -p "$cache_root"
191+ tar -C "$cache_root" -xzf /tmp/go.tar.gz
192+ fi
193+ export GOCACHE="$PWD/${cache_root}/gocache"
194+ export GOMODCACHE="$PWD/${cache_root}/gomodcache"
195+ export PATH="$PWD/${go_root}/bin:$PATH"
169196 go version
170197
171198 archive_dir="dist/${TARGET}/archive"