Skip to content

Commit

Permalink
Merge pull request #123 from signalhunter/docker-build
Browse files Browse the repository at this point in the history
Docker ARM build
  • Loading branch information
KoalaBear84 committed Oct 2, 2022
2 parents b68950d + b07d409 commit 7c0fd02
Showing 1 changed file with 54 additions and 14 deletions.
68 changes: 54 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ jobs:
7z a OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}.zip ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}/*
# 7z is installed in all environments and supports unix permissions while compressing (but not while decompressing!)
- name: Upload artifact for docker job (linux-x64 normal only)
if: ${{ matrix.target == 'linux-x64' && matrix.self-contained == 'normal' }}
- name: Upload artifact for docker job (linux only)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.self-contained == 'normal' }}
uses: actions/upload-artifact@v2
with:
name: linux-x64
name: ${{ matrix.target }}
path: |
OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}.zip
src/Dockerfile
Expand Down Expand Up @@ -132,21 +132,39 @@ jobs:

docker:
needs: build

strategy:
matrix:
target:
- linux-x64
- linux-arm
- linux-arm64
include:
- target: linux-x64
platform: linux/amd64
- target: linux-arm
platform: linux/arm/v7
- target: linux-arm64
platform: linux/arm64

runs-on: ubuntu-latest
steps:
- name: Get version info
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}

- name: Download artifact linux-x64
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: linux-x64
name: ${{ matrix.target }}

- name: Decompress artifact linux-x64
- name: Decompress artifact
uses: TonyBogdanov/zip@1.0
with:
args: unzip -qq ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-linux-x64.zip -d ./app
args: unzip -qq ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.zip -d ./app

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -156,18 +174,40 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get tag info
id: tag_info
run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./src/Dockerfile
platforms: ${{ matrix.platform }}
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:latest
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:${{ steps.tag_info.outputs.SOURCE_TAG }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:${{ matrix.target }}

combine:
needs: docker
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get tag info
id: tag_info
run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}

- name: Combine images
run: >
docker buildx imagetools create
-t ${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:latest
-t ${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:${{ steps.tag_info.outputs.SOURCE_TAG }}
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:linux-x64
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:linux-arm
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:linux-arm64

0 comments on commit 7c0fd02

Please sign in to comment.