Skip to content

Commit 9990cfe

Browse files
authored
Merge pull request #1320 from tinaboyce/1319-fix-gha-cache-failed
fix: gha setup go cache issue [#1319]
2 parents 8d9068b + 36c8b29 commit 9990cfe

File tree

2 files changed

+98
-91
lines changed

2 files changed

+98
-91
lines changed

.github/workflows/go.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
matrix:
1515
os: [ubuntu-latest, macOS-latest, macos-12]
1616
steps:
17+
- name: Check out code into the Go module directory
18+
uses: actions/checkout@v4
19+
1720
- name: Set up Go 1.x
1821
uses: actions/setup-go@v5
1922
with:
20-
go-version: 1.21.x
21-
22-
- name: Check out code into the Go module directory
23-
uses: actions/checkout@v4
23+
go-version-file: "go.mod"
2424

2525
- name: Test
2626
run: |
@@ -41,13 +41,13 @@ jobs:
4141
name: lint
4242
runs-on: ubuntu-latest
4343
steps:
44+
- name: Check out code into the Go module directory
45+
uses: actions/checkout@v4
46+
4447
- name: Set up Go 1.x
4548
uses: actions/setup-go@v5
4649
with:
47-
go-version: 1.21.x
48-
49-
- name: Check out code into the Go module directory
50-
uses: actions/checkout@v4
50+
go-version-file: "go.mod"
5151

5252
- name: golangci-lint
5353
uses: golangci/golangci-lint-action@v6
@@ -63,14 +63,17 @@ jobs:
6363
needs: [build]
6464
steps:
6565
- uses: actions/checkout@v4
66+
6667
- uses: actions/download-artifact@v4
6768
with:
6869
name: ubuntu-latest_reports
6970
path: reports
71+
7072
- uses: actions/download-artifact@v4
7173
with:
7274
name: macOS-latest_reports
7375
path: reports
76+
7477
- uses: actions/download-artifact@v4
7578
with:
7679
name: macos-12_reports
@@ -92,13 +95,13 @@ jobs:
9295
- macos-latest
9396
runs-on: ${{ matrix.os }}
9497
steps:
98+
- name: Check out code into the Go module directory
99+
uses: actions/checkout@v4
100+
95101
- name: Set up Go 1.x
96102
uses: actions/setup-go@v5
97103
with:
98-
go-version: 1.20.x
99-
100-
- name: Check out code into the Go module directory
101-
uses: actions/checkout@v4
104+
go-version-file: "go.mod"
102105

103106
- name: Install dependency required for linux builds
104107
if: matrix.os == 'ubuntu-20.04'

.github/workflows/release.yml

+83-79
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: release
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77
workflow_dispatch:
88
inputs:
99
tag:
10-
description: The tag to run against. This trigger only runs the MSI builder.
10+
description: The tag to run against. This trigger runs the GoReleaser and MSI builder.
1111
required: true
1212

1313
jobs:
@@ -19,98 +19,102 @@ jobs:
1919
max-parallel: 1
2020
matrix:
2121
os:
22-
- ubuntu-latest
23-
- ubuntu-20.04
24-
- macos-latest
22+
- ubuntu-latest
23+
- ubuntu-20.04
24+
- macos-latest
2525
runs-on: ${{ matrix.os }}
2626
if: github.event_name != 'workflow_dispatch'
2727
permissions: write-all
2828
steps:
29-
30-
- name: Set up Go 1.x
31-
uses: actions/setup-go@v5
32-
with:
33-
go-version: 1.21.x
34-
35-
- name: Check out code into the Go module directory
36-
uses: actions/checkout@v4
37-
38-
- name: Install dependency required for linux builds
39-
if: matrix.os == 'ubuntu-20.04'
40-
run: sudo apt-get update && sudo apt-get install -y libudev-dev
41-
42-
- name: Add Lowercase Repository Name to Environment
43-
run: |
44-
echo REPOSITORY_NAME_LOWERCASE=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
45-
46-
- uses: "docker/login-action@v3"
47-
if: matrix.os == 'ubuntu-20.04'
48-
with:
49-
registry: "ghcr.io"
50-
username: "${{ github.actor }}"
51-
password: "${{ secrets.GITHUB_TOKEN }}"
52-
- name: GoReleaser
53-
uses: goreleaser/goreleaser-action@v6
54-
with:
55-
version: latest
56-
args: release --clean --config .goreleaser.${{ matrix.os }}.yml
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
IMAGE_NAME: ${{ env.REPOSITORY_NAME_LOWERCASE }}
29+
- name: Check out code into the Go module directory
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Set up Go 1.x
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version-file: "go.mod"
38+
39+
- name: Install dependency required for linux builds
40+
if: matrix.os == 'ubuntu-20.04'
41+
run: sudo apt-get update && sudo apt-get install -y libudev-dev
42+
43+
- name: Add Lowercase Repository Name to Environment
44+
run: |
45+
echo REPOSITORY_NAME_LOWERCASE=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
46+
47+
- uses: "docker/login-action@v3"
48+
if: matrix.os == 'ubuntu-20.04'
49+
with:
50+
registry: "ghcr.io"
51+
username: "${{ github.actor }}"
52+
password: "${{ secrets.GITHUB_TOKEN }}"
53+
54+
- name: GoReleaser
55+
uses: goreleaser/goreleaser-action@v6
56+
with:
57+
version: latest
58+
args: release --clean --config .goreleaser.${{ matrix.os }}.yml
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
IMAGE_NAME: ${{ env.REPOSITORY_NAME_LOWERCASE }}
6062

6163
windows-msi:
6264
name: Build Windows MSI and upload to release
6365
runs-on: ubuntu-latest
6466
permissions:
6567
contents: write
6668
needs: [release]
67-
if: >- # https://github.com/actions/runner/issues/491
69+
if: >- # https://github.com/actions/runner/issues/491
6870
always() &&
6971
(needs.release.result == 'success' || needs.release.result == 'skipped')
7072
env:
7173
INSTALLER: ${{ github.workspace }}/.github/win-msi
7274
BIN: ${{ github.workspace }}/.github/win-msi/src/bin
7375
WIXIMG: dactiv/wix@sha256:17d232708589641f5632f9a1ff9463ad087b192cea7b8e6012d2b47ec6af5f6c
7476
steps:
75-
- name: Normalize tag values
76-
run: |
77-
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] ; then
78-
VER=${{ github.event.inputs.tag }}
79-
else
80-
VER=${GITHUB_REF/refs\/tags\//}
81-
fi
82-
83-
VERSION=${VER//v}
84-
85-
echo "VER_TAG=$VER" >> $GITHUB_ENV
86-
echo "VERSION=$VERSION" >> $GITHUB_ENV
87-
echo "ASSET=saml2aws_${VERSION}_windows_amd64.zip" >> $GITHUB_ENV
88-
89-
- name: Check out code
90-
uses: actions/checkout@v4
91-
92-
- name: Retrieve the release asset
93-
id: asset
94-
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2 # v1.11
95-
with:
96-
repository: ${{ github.repository }}
97-
tag: ${{ env.VER_TAG }}
98-
fileName: ${{ env.ASSET }}
99-
out-file-path: ${{ env.BIN }}
100-
101-
- name: Unzip asset
102-
working-directory: ${{ env.BIN }}
103-
run: unzip "${ASSET}"
104-
105-
- name: Build MSI
106-
run: |
107-
# container does not run as root
108-
chmod -R o+rw "${INSTALLER}"
109-
110-
cat "${INSTALLER}/wix.sh" | docker run --rm -i -e VERSION -v "${INSTALLER}:/wix" ${WIXIMG} /bin/sh
111-
112-
- name: Upload the asset to the release
113-
uses: softprops/action-gh-release@a74c6b72af54cfa997e81df42d94703d6313a2d0 # v0.2.0.6.2.0.65 / v2.0.6
114-
with:
115-
tag_name: ${{ env.VER_TAG }}
116-
files: ${{ env.INSTALLER }}/out/*.msi
77+
- name: Normalize tag values
78+
run: |
79+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] ; then
80+
VER=${{ github.event.inputs.tag }}
81+
else
82+
VER=${GITHUB_REF/refs\/tags\//}
83+
fi
84+
85+
VERSION=${VER//v}
86+
87+
echo "VER_TAG=$VER" >> $GITHUB_ENV
88+
echo "VERSION=$VERSION" >> $GITHUB_ENV
89+
echo "ASSET=saml2aws_${VERSION}_windows_amd64.zip" >> $GITHUB_ENV
90+
91+
- name: Check out code
92+
uses: actions/checkout@v4
93+
with:
94+
fetch-depth: 0
95+
96+
- name: Retrieve the release asset
97+
id: asset
98+
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2 # v1.11
99+
with:
100+
repository: ${{ github.repository }}
101+
tag: ${{ env.VER_TAG }}
102+
fileName: ${{ env.ASSET }}
103+
out-file-path: ${{ env.BIN }}
104+
105+
- name: Unzip asset
106+
working-directory: ${{ env.BIN }}
107+
run: unzip "${ASSET}"
108+
109+
- name: Build MSI
110+
run: |
111+
# container does not run as root
112+
chmod -R o+rw "${INSTALLER}"
113+
114+
cat "${INSTALLER}/wix.sh" | docker run --rm -i -e VERSION -v "${INSTALLER}:/wix" ${WIXIMG} /bin/sh
115+
116+
- name: Upload the asset to the release
117+
uses: softprops/action-gh-release@a74c6b72af54cfa997e81df42d94703d6313a2d0 # v0.2.0.6.2.0.65 / v2.0.6
118+
with:
119+
tag_name: ${{ env.VER_TAG }}
120+
files: ${{ env.INSTALLER }}/out/*.msi

0 commit comments

Comments
 (0)