Skip to content

Commit 9cdbd36

Browse files
authored
Merge pull request #25 from capito27/gh-auto-docker
Publish to dockerhub when a tag is pushed
2 parents ce6e6e6 + ba33849 commit 9cdbd36

File tree

1 file changed

+67
-20
lines changed

1 file changed

+67
-20
lines changed

.github/workflows/build.yml

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
build-windows-artifact:
3333
name: build-windows-artifact
3434
runs-on: windows-latest
35-
needs: build-linux-artifact
3635
steps:
3736
- uses: actions/checkout@v2
3837
with:
@@ -77,39 +76,87 @@ jobs:
7776
with:
7877
name: windows-binary
7978
path: bin/gpu-miner_*.exe
80-
81-
- name: Get linux artifact (Release prep)
82-
if: startsWith(github.ref, 'refs/tags/')
79+
80+
release:
81+
name: release
82+
runs-on: ubuntu-latest
83+
# If both artifacts were built properly and this is a tag
84+
if: ${{ needs.build-linux-artifact.result == 'success' && needs.build-linux-artifact.result == 'success' && startsWith(github.ref, 'refs/tags/') }}
85+
needs: [build-linux-artifact, build-windows-artifact]
86+
steps:
87+
- uses: actions/checkout@v2
88+
89+
- name: Get linux artifact
8390
uses: actions/download-artifact@v2
8491
with:
8592
name: linux-binary
86-
path: bin/
93+
94+
- name: Get Windows artifact
95+
uses: actions/download-artifact@v2
96+
with:
97+
name: windows-binary
8798

8899
- name: Get the version (Release prep)
89-
if: startsWith(github.ref, 'refs/tags/')
90100
id: get_version
91101
run: |
92102
version=$(echo ${GITHUB_REF/refs\/tags\//} | cut -c 2-)
93103
echo ::set-output name=VERSION::$version
94104
shell: bash
95105

96106
- name: Generate miners checksums (Release prep)
97-
if: startsWith(github.ref, 'refs/tags/')
98107
run: |
99-
$fileName = git rev-parse --short HEAD
100-
$hash = Get-FileHash -Algorithm SHA256 "bin/gpu-miner.exe" | Select -ExpandProperty "Hash"
101-
Write-Output $hash.ToLower()"alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe" | Out-File -FilePath "bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum"
102-
mv "bin/gpu-miner.exe" "bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe"
103-
$hash = Get-FileHash -Algorithm SHA256 "bin\gpu-miner_$fileName" | Select -ExpandProperty "Hash"
104-
Write-Output $hash.ToLower()"alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux" | Out-File -FilePath "bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum"
105-
mv "bin\gpu-miner_$fileName" "bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux"
106-
dir bin
108+
filename=$(git rev-parse --short HEAD)
109+
mv "gpu-miner_$filename" "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux"
110+
mv "gpu-miner_$filename.exe" "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe"
111+
sha256sum "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux" > "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum"
112+
sha256sum "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe" > "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum"
113+
ls -la
114+
107115
- name: Release
108116
uses: softprops/action-gh-release@v1
109-
if: startsWith(github.ref, 'refs/tags/')
110117
with:
111118
files: |
112-
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux
113-
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum
114-
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe
115-
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum
119+
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux
120+
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum
121+
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe
122+
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum
123+
124+
buildx_and_push_to_registry:
125+
name: Push Docker image to Docker Hub
126+
runs-on: ubuntu-latest
127+
if: ${{ needs.release.result == 'success' }}
128+
needs: release
129+
steps:
130+
- name: Check out the repo
131+
uses: actions/checkout@v2
132+
133+
- uses: docker/setup-qemu-action@v1
134+
- uses: docker/setup-buildx-action@v1
135+
136+
- name: Get the version
137+
id: get_version
138+
run: |
139+
version=$(git describe --tags --abbrev=0)
140+
echo $version
141+
echo ${version:1}
142+
echo ::set-output name=VERSION::$version
143+
echo ::set-output name=VERSION-NO-V::${version:1}
144+
shell: bash
145+
146+
- name: Log in to Docker Hub
147+
uses: docker/login-action@v1
148+
with:
149+
username: ${{ secrets.DOCKER_USERNAME }}
150+
password: ${{ secrets.DOCKER_PASSWORD }}
151+
152+
- name: Build and publish docker image
153+
uses: docker/build-push-action@v2
154+
with:
155+
context: .
156+
file: ./Dockerfile
157+
build-args: RELEASE=${{ steps.get_version.outputs.VERSION-NO-V }}
158+
platforms: linux/amd64
159+
tags: |
160+
docker.io/alephium/gpu-miner:${{ steps.get_version.outputs.VERSION }}
161+
docker.io/alephium/gpu-miner:latest
162+
push: true

0 commit comments

Comments
 (0)