Skip to content

Commit

Permalink
cicd: add caches to release workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Nov 1, 2021
1 parent 29d9153 commit bfc1abd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/cut-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,39 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache Go Modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-mod-${{ needs.config.outputs.go_version }}-${{ runner.os }}-${{ hashFiles('./go.*') }}
restore-keys: |
go-mod-${{ needs.config.outputs.go_version }}-${{ runner.os }}
go-mod-${{ needs.config.outputs.go_version }}
go-mod
- name: Create Release Archive
run: |
go mod vendor
git archive --prefix '${{ needs.config.outputs.tar_prefix }}' -o clair.tar "${GITHUB_REF}"
tar -rf clair.tar --transform 's,^,${{ needs.config.outputs.tar_prefix }},' vendor
gzip clair.tar
mv clair.tar.gz clair-${{ needs.config.outputs.version }}.tar.gz
- name: ChangeLog
- name: Cache Changelog
uses: actions/cache@v2
id: chlog-cache
if: github.event_name != 'workflow_dispatch'
with:
path: /usr/local/bin/git-chlog
key: changelog-${{ needs.config.output.chlog_version }}
- name: Fetch Changelog
if: steps.chlog-cache.outputs.cache-hit != 'true' && github.event_name != 'workflow_dispatch'
run: |
cd "$RUNNER_TEMP"
v="${{ needs.config.output.chlog_version }}"
f="git-chglog_${v}_linux_amd64.tar.gz"
curl -fsOSL "https://github.com/git-chglog/git-chglog/releases/download/v${v}/${f}"
tar xvf "${f}"
install git-chlog /usr/local/bin
- name: Generate changelog
shell: bash
if: github.event_name != 'workflow_dispatch'
run: |
Expand Down Expand Up @@ -106,6 +131,14 @@ jobs:
id: download
with:
name: release
- name: Cache Go Builds
uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: go-build-${{ needs.config.outputs.build_cache_key }}-${{ runner.os }}
restore-keys: |
go-build-${{ needs.config.outputs.build_cache_key }}
go-build
- name: Unpack and Build
run: |
tar -xz -f ${{steps.download.outputs.download-path}}/clair-${{ needs.config.outputs.version }}.tar.gz --strip-components=1
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,10 @@ jobs:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Go Toolchain
uses: actions/cache@v2
id: go-toolchain-cache
- name: Setup Go
uses: actions/setup-go@v2
with:
path: ~/.local/go
key: golang-${{ steps.setup.outputs.go_version }}-${{ runner.os }}
- name: Get a supported go version
if: steps.go-toolchain-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.local
curl -sSLf "https://golang.org/dl/go${{ steps.setup.outputs.go_version }}.$(go env GOOS)-$(go env GOARCH).tar.gz" |\
tar -xzC ~/.local
go-version: ${{ steps.setup.output.go_version }}
- name: Checkout
uses: actions/checkout@v2
with:
Expand Down

0 comments on commit bfc1abd

Please sign in to comment.