Skip to content

Commit df6e49c

Browse files
committed
.github/workflows: upgrade all Actions versions
In commit b7fa3a5 of PR git-lfs#5236 we replaced the deprecated actions/setup-ruby@v1 GitHub Action in our CI and release workflows with the current ruby/setup-ruby@v1 Action. We now update our other Actions to their respective latest versions as well: actions/checkout: v1 -> v3 actions/download-artifact: v1 -> v3 actions/setup-go: v2 -> v3 actions/upload-artifact: v1 -> v3 docker/setup-qemu-action: v1 -> v2 As of v2 of the actions/download-artifact Action, downloaded assets are not placed in a new subdirectory created with the name from the step's "name" argument, but in the current working directory instead. We want to retain the previous behaviour so we add a "path" argument with the same name as each of the macos-assets and windows-assets download steps. By default, the actions/checkout Action (as of v2) performs a Git fetch with a --depth=1 option, so a shallow clone is made. As a result, when our Makefile calls "git describe HEAD" to set its VERSION variable, no tags are available and Git responds with an error message. Many of our workflow jobs succeed despite logging that error, including the build-docker and build-docker-cross jobs in both our CI and Release workflows. (The Docker builds create upload artifacts with the correct filenames despite the lack of any tags because they rely on the Git LFS version strings in our debian/changelog file and in our binary; the rpm/build_rpms.bsh script builds a binary just to run "git-lfs version" and determine the version string from its output.) However, our workflow jobs which run the "make release" command fail outright in the absence of any Git tags, as they search for build artifacts using filenames constructed with the empty VERSION variable, such as "git-lfs-windows-amd64-.zip". When no files are found, the tar command fails, halting the job. This affects both the build-default job in our CI workflow (for Linux and macOS), and all of build-main, build-macos, and build-windows jobs in our Release workflow. To resolve this in the case of a PR or other push to a branch, we set a fetch-depth value of 0 for our actions/checkout@v3 steps, which downloads the full Git history and all tags. This is somewhat more expensive than a shallow clone, but our project's history is not excessively large. Due to the GitHub Actions bug documented in actions/checkout#882, though, this resolution is insufficient in the case of a push to a tag. At present, the actions/checkout@v3 incorrectly determines the SHA of an annotated tag to be the SHA of its associated commit, and then proceeds as if the tag had been updated on the server since the Action was started, and so rewrites the tag locally to refer to the commit SHA. This has the effect of making the local tag into a lightweight tag, which "git describe" then ignores (since we don't pass the --tags option to it). As a temporary fix for this problem, we add a step after the actions/checkout@v3 step which updates the local tag again to match the remote one. We only run this step when the pushed reference was a tag, because on a branch push it would fail as Git would refuse to update the currently checked-out branch. In our Release workflow, since it only runs on pushes to tags, we can run this step unconditionally. (We could also continue to use the default fetch-depth of 1 for the actions/checkout@v3 step, since we always subsequently fetch the relevant tag, but to be consistent and to avoid future issues once actions/checkout#882 is fixed upstream, we do not do so.)
1 parent ba2fae4 commit df6e49c

File tree

2 files changed

+79
-26
lines changed

2 files changed

+79
-26
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ jobs:
1010
go: ['1.19.x']
1111
runs-on: ${{ matrix.os }}
1212
steps:
13-
- uses: actions/checkout@v1
13+
- uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
17+
if: ${{ github.ref_type == 'tag' }}
18+
# We update the current tag as the checkout step turns annotated tags
19+
# into lightweight ones by accident, breaking "git describe".
20+
# See https://github.com/actions/checkout/issues/882 for details.
1421
- uses: ruby/setup-ruby@v1
1522
- run: gem install asciidoctor
16-
- uses: actions/setup-go@v2
23+
- uses: actions/setup-go@v3
1724
with:
1825
go-version: ${{ matrix.go }}
1926
- run: brew install gettext
@@ -30,7 +37,7 @@ jobs:
3037
FORCE_LOCALIZE: true
3138
- run: mkdir -p bin/assets
3239
- run: find bin/releases -name "*$(uname -s | tr A-Z a-z)*" | xargs -I{} cp {} bin/assets
33-
- uses: actions/upload-artifact@v1
40+
- uses: actions/upload-artifact@v3
3441
with:
3542
name: ${{ matrix.os }}
3643
path: bin/assets
@@ -41,22 +48,31 @@ jobs:
4148
go: ['1.18.x']
4249
runs-on: ubuntu-latest
4350
steps:
44-
- uses: actions/checkout@v1
45-
- uses: actions/setup-go@v2
51+
- uses: actions/checkout@v3
52+
with:
53+
fetch-depth: 0
54+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
55+
if: ${{ github.ref_type == 'tag' }}
56+
- uses: actions/setup-go@v3
4657
with:
4758
go-version: ${{ matrix.go }}
4859
- run: script/cibuild
4960
build-windows:
5061
name: Build on Windows
5162
runs-on: windows-latest
5263
steps:
53-
- uses: actions/checkout@v1
64+
- uses: actions/checkout@v3
65+
with:
66+
fetch-depth: 0
67+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
68+
if: ${{ github.ref_type == 'tag' }}
69+
shell: bash
5470
- uses: ruby/setup-ruby@v1
5571
- run: gem install asciidoctor
5672
- run: Rename-Item -Path C:\msys64 -NewName msys64-tmp -Force
5773
# We move the MSYS2 installed for Ruby aside to prevent use of its Git,
5874
# which does not honour the PATH we set to our built git-lfs binary.
59-
- uses: actions/setup-go@v2
75+
- uses: actions/setup-go@v3
6076
with:
6177
go-version: '1.19.x'
6278
- run: mkdir -p "$HOME/go/bin"
@@ -99,7 +115,7 @@ jobs:
99115
shell: bash
100116
- run: mv *.exe bin/assets
101117
shell: bash
102-
- uses: actions/upload-artifact@v1
118+
- uses: actions/upload-artifact@v3
103119
with:
104120
name: windows-latest
105121
path: bin/assets
@@ -110,7 +126,11 @@ jobs:
110126
os: [ubuntu-latest, macos-latest]
111127
runs-on: ${{ matrix.os }}
112128
steps:
113-
- uses: actions/checkout@v1
129+
- uses: actions/checkout@v3
130+
with:
131+
fetch-depth: 0
132+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
133+
if: ${{ github.ref_type == 'tag' }}
114134
- run: git clone -b master https://github.com/git/git.git "$HOME/git"
115135
- run: script/build-git "$HOME/git"
116136
- run: GIT_DEFAULT_HASH=sha256 script/cibuild
@@ -121,15 +141,23 @@ jobs:
121141
os: [ubuntu-latest, macos-latest]
122142
runs-on: ${{ matrix.os }}
123143
steps:
124-
- uses: actions/checkout@v1
144+
- uses: actions/checkout@v3
145+
with:
146+
fetch-depth: 0
147+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
148+
if: ${{ github.ref_type == 'tag' }}
125149
- run: git clone -b v2.0.0 https://github.com/git/git.git "$HOME/git"
126150
- run: script/build-git "$HOME/git"
127151
- run: script/cibuild
128152
build-docker:
129153
name: Build Linux packages
130154
runs-on: ubuntu-latest
131155
steps:
132-
- uses: actions/checkout@v1
156+
- uses: actions/checkout@v3
157+
with:
158+
fetch-depth: 0
159+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
160+
if: ${{ github.ref_type == 'tag' }}
133161
- uses: ruby/setup-ruby@v1
134162
- run: git clone https://github.com/git-lfs/build-dockers.git "$HOME/build-dockers"
135163
- run: (cd "$HOME/build-dockers" && ./build_dockers.bsh)
@@ -142,13 +170,17 @@ jobs:
142170
arch: [arm64]
143171
container: [debian_11]
144172
steps:
145-
- uses: actions/checkout@v1
173+
- uses: actions/checkout@v3
174+
with:
175+
fetch-depth: 0
176+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
177+
if: ${{ github.ref_type == 'tag' }}
146178
- uses: ruby/setup-ruby@v1
147179
- run: |
148180
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
149181
sudo systemctl restart docker.service
150182
docker version -f '{{.Server.Experimental}}'
151-
- uses: docker/setup-qemu-action@v1
183+
- uses: docker/setup-qemu-action@v2
152184
- run: git clone https://github.com/git-lfs/build-dockers.git "$HOME/build-dockers"
153185
- run: (cd "$HOME/build-dockers" && ./build_dockers.bsh --arch=$ARCH $CONTAINER)
154186
env:

.github/workflows/release.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ jobs:
1111
matrix:
1212
go: ['1.19.x']
1313
steps:
14-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
18+
shell: bash
19+
# We update the current tag as the checkout step turns annotated tags
20+
# into lightweight ones by accident, breaking "git describe".
21+
# See https://github.com/actions/checkout/issues/882 for details.
1522
- uses: ruby/setup-ruby@v1
1623
- run: gem install asciidoctor
1724
- run: Rename-Item -Path C:\msys64 -NewName msys64-tmp -Force
1825
# We move the MSYS2 installed for Ruby aside to prevent use of its Git,
1926
# which does not honour the PATH we set to our built git-lfs binary.
20-
- uses: actions/setup-go@v2
27+
- uses: actions/setup-go@v3
2128
with:
2229
go-version: ${{ matrix.go }}
2330
- run: mkdir -p "$HOME/go/bin"
@@ -57,7 +64,7 @@ jobs:
5764
FORCE_LOCALIZE: true
5865
- run: env -u TMPDIR make release-windows-rebuild
5966
shell: bash
60-
- uses: actions/upload-artifact@v1
67+
- uses: actions/upload-artifact@v3
6168
with:
6269
name: windows-assets
6370
path: bin/releases
@@ -68,10 +75,13 @@ jobs:
6875
matrix:
6976
go: ['1.19.x']
7077
steps:
71-
- uses: actions/checkout@v1
78+
- uses: actions/checkout@v3
79+
with:
80+
fetch-depth: 0
81+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
7282
- uses: ruby/setup-ruby@v1
7383
- run: gem install asciidoctor
74-
- uses: actions/setup-go@v2
84+
- uses: actions/setup-go@v3
7585
with:
7686
go-version: ${{ matrix.go }}
7787
- run: brew install gettext
@@ -90,7 +100,7 @@ jobs:
90100
DARWIN_DEV_USER: ${{secrets.MACOS_DEV_USER}}
91101
DARWIN_DEV_PASS: ${{secrets.MACOS_DEV_PASS}}
92102
DARWIN_CERT_ID: ${{secrets.MACOS_CERT_ID}}
93-
- uses: actions/upload-artifact@v1
103+
- uses: actions/upload-artifact@v3
94104
with:
95105
name: macos-assets
96106
path: bin/releases
@@ -104,21 +114,26 @@ jobs:
104114
matrix:
105115
go: ['1.19.x']
106116
steps:
107-
- uses: actions/checkout@v1
117+
- uses: actions/checkout@v3
118+
with:
119+
fetch-depth: 0
120+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
108121
- uses: ruby/setup-ruby@v1
109122
- run: gem install asciidoctor
110-
- uses: actions/setup-go@v2
123+
- uses: actions/setup-go@v3
111124
with:
112125
go-version: ${{ matrix.go }}
113126
- run: sudo apt-get update && sudo apt-get -y install gettext libarchive-tools
114127
env:
115128
DEBIAN_FRONTEND: noninteractive
116-
- uses: actions/download-artifact@v1
129+
- uses: actions/download-artifact@v3
117130
with:
118131
name: windows-assets
119-
- uses: actions/download-artifact@v1
132+
path: windows-assets
133+
- uses: actions/download-artifact@v3
120134
with:
121135
name: macos-assets
136+
path: macos-assets
122137
- run: CGO_ENABLED=0 make release
123138
- run: rm -f bin/releases/*windows* bin/releases/*darwin*
124139
- run: 'find windows-assets -name "*windows*" -type f | xargs -I{} mv {} bin/releases'
@@ -130,7 +145,10 @@ jobs:
130145
name: Build Linux Packages
131146
runs-on: ubuntu-latest
132147
steps:
133-
- uses: actions/checkout@v1
148+
- uses: actions/checkout@v3
149+
with:
150+
fetch-depth: 0
151+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
134152
- uses: ruby/setup-ruby@v1
135153
- run: gem install packagecloud-ruby
136154
- run: git clone https://github.com/git-lfs/build-dockers.git "$HOME/build-dockers"
@@ -148,14 +166,17 @@ jobs:
148166
arch: [arm64]
149167
container: [debian_11]
150168
steps:
151-
- uses: actions/checkout@v1
169+
- uses: actions/checkout@v3
170+
with:
171+
fetch-depth: 0
172+
- run: git fetch origin "+${GITHUB_REF}:${GITHUB_REF}"
152173
- uses: ruby/setup-ruby@v1
153174
- run: gem install packagecloud-ruby
154175
- run: |
155176
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
156177
sudo systemctl restart docker.service
157178
docker version -f '{{.Server.Experimental}}'
158-
- uses: docker/setup-qemu-action@v1
179+
- uses: docker/setup-qemu-action@v2
159180
- run: git clone https://github.com/git-lfs/build-dockers.git "$HOME/build-dockers"
160181
- run: (cd "$HOME/build-dockers" && ./build_dockers.bsh --arch=$ARCH $CONTAINER)
161182
env:

0 commit comments

Comments
 (0)