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
73 with:73 with:
74 go-version: ${{ env.GO_VERSION }}74 go-version: ${{ env.GO_VERSION }}
75 cache: true75 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 }}-
76 - name: Generate Build Metadata85 - name: Generate Build Metadata
77 shell: bash86 shell: bash
78 run: |87 run: |
@@ -143,6 +152,16 @@ jobs: · 64 unmodified lines
143 git show FETCH_HEAD:models.json > internal/registry/models/models.json152 git show FETCH_HEAD:models.json > internal/registry/models/models.json
144 - name: Fetch tags153 - name: Fetch tags
145 run: git fetch --force --tags154 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 }}-
146 - name: Generate Build Metadata165 - name: Generate Build Metadata
147 run: |166 run: |
148 echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV167 echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
@@ -162,10 +181,18 @@ jobs: · 13 unmodified lines
162 shell: cpa.sh {0}181 shell: cpa.sh {0}
163 run: |182 run: |
164 set -eu183 set -eu
165 fetch -o /tmp/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.freebsd-${GOARCH}.tar.gz"184 cache_root=".freebsd-cache/${GOARCH}"
166 rm -rf /tmp/go185 go_root="${cache_root}/go"
167 tar -C /tmp -xzf /tmp/go.tar.gz186 mkdir -p "${cache_root}/gocache" "${cache_root}/gomodcache"
168 export PATH="/tmp/go/bin:$PATH"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"
169 go version196 go version
170 197
171 archive_dir="dist/${TARGET}/archive"198 archive_dir="dist/${TARGET}/archive"