From d09ee966f24ab2337d402905d874b38ee358c37b Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Fri, 12 Nov 2021 16:28:22 -0800 Subject: [PATCH 1/8] Add releases and Docker container --- .github/workflows/build.yml | 31 -------------- .github/workflows/linux-build.yml | 63 +++++++++++++++++++++++++++++ .github/workflows/macos-build.yml | 33 +++++++++++++++ .github/workflows/windows-build.yml | 39 ++++++++++++++++++ Dockerfile | 11 +++++ 5 files changed, 146 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/linux-build.yml create mode 100644 .github/workflows/macos-build.yml create mode 100644 .github/workflows/windows-build.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 6ba95e56..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will build Comet on Unix-like systems. -name: Build and test - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - unix-build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - - steps: - - uses: actions/checkout@v2 - - name: Build Comet - run: make - - windows-build: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - name: Setup msbuild - uses: microsoft/setup-msbuild@v1.1 - - - name: Build Comet - run: | - msbuild Comet.sln -p:Configuration=Release -p:Platform=x64 -p:PlatformToolset=v142 -tv:Current diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml new file mode 100644 index 00000000..f72a96ab --- /dev/null +++ b/.github/workflows/linux-build.yml @@ -0,0 +1,63 @@ +name: Build and Release on Linux + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + release: + types: [ created ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: uwpr/comet + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build Comet + run: make && ./comet.exe -p + + - name: Prepare release + run: | + mkdir release && \ + cp comet.exe release/comet && \ + cp README.md release/README.md && \ + tar -czv linux.tar.gz release + + - name: Upload binaries to the release + uses: svenstaro/upload-release-action@v2 + if: ${{ github.event_name == 'release' }} + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + file: linux.tar.gz + overwrite: true + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Log in to the GitHub Container registry + if: ${{ github.event_name == 'release' }} + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name == 'release' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Test the Docker image + if: ${{ github.event_name != 'release' }} + run: docker run ${REGISTRY}/${{ env.IMAGE_NAME }}:main comet -p diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml new file mode 100644 index 00000000..c571ba01 --- /dev/null +++ b/.github/workflows/macos-build.yml @@ -0,0 +1,33 @@ +name: Build and Release on MacOS + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + release: + types: [ created ] + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Build Comet + run: make && ./comet.exe -p + + - name: Prepare release + run: | + mkdir release && \ + cp comet.exe release/comet && \ + cp README.md release/README.md && \ + zip -r macos.zip release + + - name: Upload binaries to the release + uses: svenstaro/upload-release-action@v2 + if: ${{ github.event_name == 'release' }} + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + file: macos.zip + overwrite: true diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml new file mode 100644 index 00000000..549f4a04 --- /dev/null +++ b/.github/workflows/windows-build.yml @@ -0,0 +1,39 @@ +name: Build and Release on Windows + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + release: + types: [ created ] + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup msbuild + uses: microsoft/setup-msbuild@v1.1 + + - name: Build Comet + run: | + msbuild Comet.sln -p:Configuration=Release -p:Platform=x64 -p:PlatformToolset=v142 -tv:Current + + - name: Prepare release + shell: bash + run: | + mkdir release && \ + cp comet.exe release/comet.exe && \ + cp README.md release/README.md && \ + zip -r windows.zip release + + - name: Upload binaries to the release + uses: svenstaro/upload-release-action@v2 + if: ${{ github.event_name == 'release' }} + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + file: windows.zip + overwrite: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..b468722c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:18.04 + +RUN apt-get update && \ + apt-get install procps -y && \ + apt-get clean + +WORKDIR /app + +COPY comet.exe ./comet + +ENV PATH="/app:$PATH" From 60103558fee897b33142e0721624883924859e07 Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Fri, 12 Nov 2021 16:53:39 -0800 Subject: [PATCH 2/8] Fix archiving --- .github/workflows/linux-build.yml | 4 ++-- .github/workflows/macos-build.yml | 2 +- .github/workflows/windows-build.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index f72a96ab..fc68e358 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -1,4 +1,4 @@ -name: Build and Release on Linux +name: Build on Linux on: push: @@ -25,7 +25,7 @@ jobs: mkdir release && \ cp comet.exe release/comet && \ cp README.md release/README.md && \ - tar -czv linux.tar.gz release + tar -czf linux.tar.gz release - name: Upload binaries to the release uses: svenstaro/upload-release-action@v2 diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index c571ba01..c7e4a4cb 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -1,4 +1,4 @@ -name: Build and Release on MacOS +name: Build on MacOS on: push: diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 549f4a04..115bfde0 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -1,4 +1,4 @@ -name: Build and Release on Windows +name: Build on Windows on: push: From 8678265b77939e9c62bda8461502145d33f53729 Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Fri, 12 Nov 2021 16:58:58 -0800 Subject: [PATCH 3/8] Update Docker image test --- .github/workflows/linux-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index fc68e358..6deb47fd 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -60,4 +60,4 @@ jobs: - name: Test the Docker image if: ${{ github.event_name != 'release' }} - run: docker run ${REGISTRY}/${{ env.IMAGE_NAME }}:main comet -p + run: docker run ${REGISTRY}/${{ env.IMAGE_NAME }}:${{ steps.meta.output.tags }} comet -p From e61d0a5975c2a431db12b22099506147319ade2e Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Fri, 12 Nov 2021 17:02:59 -0800 Subject: [PATCH 4/8] Try glob with Docker --- .github/workflows/linux-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 6deb47fd..d365a823 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -60,4 +60,4 @@ jobs: - name: Test the Docker image if: ${{ github.event_name != 'release' }} - run: docker run ${REGISTRY}/${{ env.IMAGE_NAME }}:${{ steps.meta.output.tags }} comet -p + run: docker run ${REGISTRY}/${{ env.IMAGE_NAME }}* comet -p From 27916218d46f5c57746d82d14ee0a3c542c6e3a8 Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Fri, 12 Nov 2021 17:08:06 -0800 Subject: [PATCH 5/8] Try without tag --- .github/workflows/linux-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index d365a823..dfaae725 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -60,4 +60,4 @@ jobs: - name: Test the Docker image if: ${{ github.event_name != 'release' }} - run: docker run ${REGISTRY}/${{ env.IMAGE_NAME }}* comet -p + run: ls && docker run ${REGISTRY}/${{ env.IMAGE_NAME }} comet -p From cc61de2d6a16737351016801b309eaf874aa1f3c Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Sat, 13 Nov 2021 14:49:02 -0800 Subject: [PATCH 6/8] Fix Docker test and improve naming --- .github/workflows/linux-build.yml | 38 ++++++++++++++++++++--------- .github/workflows/macos-build.yml | 8 ++++-- .github/workflows/windows-build.yml | 3 +++ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index dfaae725..1418b093 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -17,10 +17,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Build Comet - run: make && ./comet.exe -p + run: make + + - name: Test Comet + run: ./comet.exe -p - - name: Prepare release + - name: Prepare Comet release run: | mkdir release && \ cp comet.exe release/comet && \ @@ -36,13 +40,17 @@ jobs: file: linux.tar.gz overwrite: true - - name: Extract metadata for Docker - id: meta - uses: docker/metadata-action@v3 + - name: Build the Docker image + uses: docker/build-push-action@v2 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + context: . + load: true + tags: ${{ env.IMAGE_NAME }}:test + + - name: Test the Docker image + run: docker run --rm ${IMAGE_NAME} comet -p - - name: Log in to the GitHub Container registry + - name: Log in to the GitHub Container Registry if: ${{ github.event_name == 'release' }} uses: docker/login-action@v1 with: @@ -50,14 +58,20 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Note that the image is cached from the test build, so it won't be build a + # second time. Correspondingly, this step only pushes it to the GitHub + # Container Registry. + - name: Push the Docker image to the GHCR uses: docker/build-push-action@v2 + if : ${{ github.event_name == 'release' }} with: context: . push: ${{ github.event_name == 'release' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - - name: Test the Docker image - if: ${{ github.event_name != 'release' }} - run: ls && docker run ${REGISTRY}/${{ env.IMAGE_NAME }} comet -p diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index c7e4a4cb..a0037508 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -13,10 +13,14 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v2 + - name: Build Comet - run: make && ./comet.exe -p + run: make + + - name: Test Comet + run: ./comet.exe -p - - name: Prepare release + - name: Prepare Comet release run: | mkdir release && \ cp comet.exe release/comet && \ diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 115bfde0..e71894dc 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -21,6 +21,9 @@ jobs: run: | msbuild Comet.sln -p:Configuration=Release -p:Platform=x64 -p:PlatformToolset=v142 -tv:Current + - name: Test Comet + run: comet.exe -p + - name: Prepare release shell: bash run: | From 386a1254c5773a6fddb54b954672258b04692dbd Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Sat, 13 Nov 2021 14:59:38 -0800 Subject: [PATCH 7/8] Use test tag --- .github/workflows/linux-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 1418b093..5deb7b2c 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -48,7 +48,7 @@ jobs: tags: ${{ env.IMAGE_NAME }}:test - name: Test the Docker image - run: docker run --rm ${IMAGE_NAME} comet -p + run: docker run --rm ${IMAGE_NAME}:test comet -p - name: Log in to the GitHub Container Registry if: ${{ github.event_name == 'release' }} @@ -59,6 +59,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker + if: ${{ github.event_name == 'release' }} id: meta uses: docker/metadata-action@v3 with: From 7019dc4e3a1b965bb38502552565c4d381c5fa03 Mon Sep 17 00:00:00 2001 From: William Fondrie Date: Sat, 13 Nov 2021 15:03:21 -0800 Subject: [PATCH 8/8] Clean up unneeded if statement --- .github/workflows/linux-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 5deb7b2c..c3f80ed6 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -73,6 +73,6 @@ jobs: if : ${{ github.event_name == 'release' }} with: context: . - push: ${{ github.event_name == 'release' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}