Skip to content

Commit

Permalink
Merge pull request #25 from capito27/gh-auto-docker
Browse files Browse the repository at this point in the history
Publish to dockerhub when a tag is pushed
  • Loading branch information
polarker authored Nov 28, 2021
2 parents ce6e6e6 + ba33849 commit 9cdbd36
Showing 1 changed file with 67 additions and 20 deletions.
87 changes: 67 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
build-windows-artifact:
name: build-windows-artifact
runs-on: windows-latest
needs: build-linux-artifact
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -77,39 +76,87 @@ jobs:
with:
name: windows-binary
path: bin/gpu-miner_*.exe

- name: Get linux artifact (Release prep)
if: startsWith(github.ref, 'refs/tags/')

release:
name: release
runs-on: ubuntu-latest
# If both artifacts were built properly and this is a tag
if: ${{ needs.build-linux-artifact.result == 'success' && needs.build-linux-artifact.result == 'success' && startsWith(github.ref, 'refs/tags/') }}
needs: [build-linux-artifact, build-windows-artifact]
steps:
- uses: actions/checkout@v2

- name: Get linux artifact
uses: actions/download-artifact@v2
with:
name: linux-binary
path: bin/

- name: Get Windows artifact
uses: actions/download-artifact@v2
with:
name: windows-binary

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

- name: Generate miners checksums (Release prep)
if: startsWith(github.ref, 'refs/tags/')
run: |
$fileName = git rev-parse --short HEAD
$hash = Get-FileHash -Algorithm SHA256 "bin/gpu-miner.exe" | Select -ExpandProperty "Hash"
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"
mv "bin/gpu-miner.exe" "bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe"
$hash = Get-FileHash -Algorithm SHA256 "bin\gpu-miner_$fileName" | Select -ExpandProperty "Hash"
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"
mv "bin\gpu-miner_$fileName" "bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux"
dir bin
filename=$(git rev-parse --short HEAD)
mv "gpu-miner_$filename" "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux"
mv "gpu-miner_$filename.exe" "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe"
sha256sum "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux" > "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum"
sha256sum "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe" > "alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum"
ls -la
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe
bin\alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-linux.checksum
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe
alephium-${{ steps.get_version.outputs.VERSION }}-cuda-miner-windows.exe.checksum
buildx_and_push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
if: ${{ needs.release.result == 'success' }}
needs: release
steps:
- name: Check out the repo
uses: actions/checkout@v2

- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1

- name: Get the version
id: get_version
run: |
version=$(git describe --tags --abbrev=0)
echo $version
echo ${version:1}
echo ::set-output name=VERSION::$version
echo ::set-output name=VERSION-NO-V::${version:1}
shell: bash

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and publish docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
build-args: RELEASE=${{ steps.get_version.outputs.VERSION-NO-V }}
platforms: linux/amd64
tags: |
docker.io/alephium/gpu-miner:${{ steps.get_version.outputs.VERSION }}
docker.io/alephium/gpu-miner:latest
push: true

0 comments on commit 9cdbd36

Please sign in to comment.