From d7e5e33f0ca519cde5f854bc6f4e7e31c2659a2e Mon Sep 17 00:00:00 2001 From: Gareth Latty Date: Sun, 8 Nov 2020 22:15:33 +0000 Subject: [PATCH] Publish to GitHub Container Registry. --- .github/workflows/build.yml | 87 +++++++++++++++++++++ .github/workflows/publish_docker_images.yml | 70 ----------------- README.md | 16 +++- 3 files changed, 100 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/publish_docker_images.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1b63c44 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,87 @@ +name: Build + +on: + push: + branches: + - main + tags: + - v*.*.* + +env: + COMMIT_VERSION: "${{ github.sha }}-dev" + +jobs: + + build: + name: Build docker images. + runs-on: ubuntu-latest + strategy: + matrix: + component: ["server", "client"] + env: + COMPONENT: ${{ matrix.component }} + steps: + - name: Checkout repository. + uses: actions/checkout@v2 + - name: Get version from tag. + uses: olegtarasov/get-tag@v2 + continue-on-error: true + - name: Build image. + run: + cd "${COMPONENT}" && + docker build -t "${COMPONENT}:${COMMIT_VERSION}" + --build-arg VCS_REF="${GITHUB_SHA}" + --build-arg BUILD_DATE="$(date --rfc-3339=seconds)" + --build-arg VERSION="${GITHUB_TAG_NAME:-${COMMIT_VERSION}}" + . + - name: Save image. + run: docker save "${COMPONENT}:${COMMIT_VERSION}" | gzip > "image.tar.gz" + - name: Store image for publish job. + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.component }} + path: image.tar.gz + + publish: + name: Publish docker images. + needs: build + runs-on: ubuntu-latest + strategy: + matrix: + component: ["server", "client"] + registry: [ + { + server: "registry.hub.docker.com", + user: "latty", + token-secret: "DOCKER_HUB_TOKEN", + path: "massivedecks", + image-prefix: "" + }, + { + server: "ghcr.io", + user: "lattyware", + token-secret: "GHCR_TOKEN", + path: "lattyware/massivedecks", + image-prefix: "" + } + ] + steps: + - name: Retrieve image from build job. + uses: actions/download-artifact@v2 + with: + name: ${{ matrix.component }} + - name: Load image. + run: docker load < "image.tar.gz" + - name: Get version from tag. + uses: olegtarasov/get-tag@v2 + - name: Publish image. + uses: lattyware/push-docker-image-to-version-tags@v2 + with: + source: "${{ matrix.component }}:${{ env.COMMIT_VERSION }}" + image: "${{ matrix.registry.image-prefix }}${{ matrix.component }}" + hash: "${{ env.COMMIT_VERSION }}" + version: "${{ env.GIT_TAG_NAME }}" + server: "${{ matrix.registry.server }}" + server_path: "${{ matrix.registry.path }}" + user: "${{ matrix.registry.user }}" + token: "${{ secrets[matrix.registry.token-secret] }}" diff --git a/.github/workflows/publish_docker_images.yml b/.github/workflows/publish_docker_images.yml deleted file mode 100644 index 3985e86..0000000 --- a/.github/workflows/publish_docker_images.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Build and publish docker images. - -on: - push: - branches: - - master - tags: - - v*.*.* - -env: - COMMIT_VERSION: "${{ github.sha }}-dev" - -jobs: - - build: - name: Build docker images. - runs-on: ubuntu-latest - strategy: - matrix: - component: ["server", "client"] - env: - COMPONENT: ${{ matrix.component }} - steps: - - name: Checkout repository. - uses: actions/checkout@v2 - - name: Get version from tag. - uses: olegtarasov/get-tag@v1 - continue-on-error: true - - name: Build image. - run: - cd "${COMPONENT}" && - docker build -t "massivedecks/${COMPONENT}:${COMMIT_VERSION}" - --build-arg VCS_REF="${GITHUB_SHA}" - --build-arg BUILD_DATE="$(date --rfc-3339=seconds)" - --build-arg VERSION="${GITHUB_TAG_NAME:-${COMMIT_VERSION}}" - . - - name: Save image. - run: docker save "massivedecks/${COMPONENT}:${COMMIT_VERSION}" | gzip > "image.tar.gz" - - name: Store image for publish job. - uses: actions/upload-artifact@v1 - with: - name: ${{ matrix.component }} - path: image.tar.gz - - publish: - name: Publish docker images. - needs: build - runs-on: ubuntu-latest - strategy: - matrix: - COMPONENT: ["server", "client"] - env: - COMPONENT: ${{ matrix.component }} - steps: - - name: Retrieve image from build job. - uses: actions/download-artifact@v1 - with: - name: ${{ matrix.component }} - - name: Load image. - run: docker load < "${COMPONENT}/image.tar.gz" - - name: Get version from tag. - uses: olegtarasov/get-tag@v1 - - name: Publish image. - uses: lattyware/push-docker-image-to-version-tags@v1 - with: - image: "massivedecks/${{ matrix.component }}" - tag: ${{ env.COMMIT_VERSION }} - version: ${{ env.GITHUB_TAG_NAME }} - user: "latty" - token: ${{ secrets.DOCKER_HUB_TOKEN }} diff --git a/README.md b/README.md index a8b8f31..744bfd5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # [Massive Decks ![Massive Decks](https://raw.githubusercontent.com/Lattyware/massivedecks/master/client/assets/images/icon.png)][hosted] -[![Build Status](https://img.shields.io/github/workflow/status/Lattyware/massivedecks/Build%20and%20publish%20docker%20images.)](https://github.com/Lattyware/massivedecks/actions) +[![Current Release Version](https://img.shields.io/github/v/tag/Lattyware/massivedecks?label=release&sort=semver)](https://github.com/Lattyware/massivedecks/releases) +[![Build Status](https://img.shields.io/github/workflow/status/Lattyware/massivedecks/Build)](https://github.com/Lattyware/massivedecks/actions) [![License](https://img.shields.io/github/license/Lattyware/massivedecks)](LICENSE) [![Follow on Twitter for Status & Updates](https://img.shields.io/twitter/follow/Massive_Decks?label=Status%20%26%20Updates&style=social)][twitter] @@ -48,7 +49,9 @@ It is suggested you read the [deployment guide on the wiki][deployment-guide]. ### Docker -The Docker images can be found on Docker Hub: [Server](https://hub.docker.com/r/massivedecks/server) / [Client](https://hub.docker.com/r/massivedecks/client). +The Docker images can be found on the GitHub Container Registry: +[Server](https://github.com/users/Lattyware/packages/container/package/massivedecks%2Fserver) / +[Client](https://github.com/users/Lattyware/packages/container/package/massivedecks%2Fclient). There are example docker deployments in [the deployment folder](deployment). @@ -75,9 +78,16 @@ The game has a system for translation, and if you would like to provide translat ## Credits +### Contributors + +Massive Decks is open source, and would not be possible without the time and work of +[the community members][github-contributors] who have contributed code and localizations. + +[github-contributors]: https://github.com/Lattyware/massivedecks/graphs/contributors + ### Maintainers -Massive Decks is maintained by [Reread Games][reread]. +[Reread Games][reread] maintains Massive Decks. If you enjoy Massive Decks, please take a look at their other games. [reread]: https://www.rereadgames.com/