Repository: briantist/galactory (language: python)

Issue:
Add ARM64 container to build
Would be nice


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 589a275..b971527 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,13 @@ python3 -m pip install galactory
 ```
 
 ## Container
+
+Latest tagged release:
 ```shell
 docker run --rm ghcr.io/briantist/galactory:latest --help
 ```
+
+Latest commit on `main`:
+```shell
+docker run --rm ghcr.io/briantist/galactory:main --help
+```
diff --git a/setup.cfg b/setup.cfg
index 6ffe4cb..a4887d4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = galactory
-version = 0.3.0
+version = 0.3.1
 url = https://github.com/briantist/galactory
 author = Brian Scholer
 license = GPLv3+


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 945a331..9411983 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -23,6 +23,9 @@ jobs:
           # - '3.11-dev'  # test broken:  AttributeError: module 'pathlib' has no attribute '_Accessor'
     env:
       PYTEST_ADDOPTS: '--color=yes'
+    outputs:
+      relver: ${{ steps.setvars.outputs.relver }}
+      branch: ${{ steps.setvars.outputs.branch }}
     steps:
       - uses: actions/checkout@v3
 
@@ -37,23 +40,48 @@ jobs:
       - name: Pytest
         run: pytest tests/
 
+      - name: Set vars
+        id: setvars
+        if: startsWith(github.ref, 'refs/tags/')
+        run: |
+          VER_TAG=${GITHUB_REF/refs\/tags\/v/}
+          echo "::set-output name=relver::${VER_TAG}"
+          echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
 
   build:
     needs: [test]
     permissions:
       contents: read
     runs-on: ubuntu-latest
-    outputs:
-      relver: ${{ steps.checkver.outputs.relver }}
     steps:
       - uses: actions/checkout@v3
 
-      - name: Build container
-        run: docker build -t galactory:latest .
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v2
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v2
+
+      - name: Build amd64
+        uses: docker/build-push-action@v3
+        with:
+          push: false
+          context: .
+          load: true
+          platforms: linux/amd64
+          tags: galactory:latest
 
       - name: Run container
         run: docker run --rm galactory --help
 
+      - name: Build arm64
+        uses: docker/build-push-action@v3
+        with:
+          push: false
+          context: .
+          platforms: linux/arm64
+          tags: galactory:latest
+
       - uses: actions/setup-python@v4
         with:
           python-version: '3.10'
@@ -71,8 +99,7 @@ jobs:
         id: checkver
         if: startsWith(github.ref, 'refs/tags/')
         run: |
-          VER_TAG=${GITHUB_REF/refs\/tags\/v/}
-          echo "::set-output name=relver::${VER_TAG}"
+          VER_TAG=${{ needs.test.outputs.relver }}
 
           expected_sdist=galactory-${VER_TAG}.tar.gz
           expected_wheel=galactory-${VER_TAG}-py3-none-any.whl
@@ -91,7 +118,7 @@ jobs:
 
 
   release:
-    needs: [build]
+    needs: [test, build]
     if: github.event_name == 'push'
     runs-on: ubuntu-latest
     env:
@@ -99,19 +126,25 @@ jobs:
     steps:
       - uses: actions/checkout@v3
 
-      - name: Build container
-        run: docker build -t ${UPSTREAM}:latest -t ${UPSTREAM}:${{ startsWith(github.ref, 'refs/tags/') && needs.build.outputs.relver || github.sha }} .
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v2
 
-      - name: Run container
-        run: docker run --rm ${UPSTREAM}:latest --help
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v2
 
       - name: Login to registry
         if: github.event_name == 'push'
         run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
 
-      - name: Push to registry
-        if: github.event_name == 'push'
-        run: docker push --all-tags ${UPSTREAM}
+      - name: Build & Push
+        uses: docker/build-push-action@v3
+        with:
+          push: ${{ github.event_name == 'push' }}
+          context: .
+          platforms: linux/amd64,linux/arm64
+          tags: |
+            ${UPSTREAM}:${{ startsWith(github.ref, 'refs/tags/') && 'latest' || needs.test.outputs.branch }}
+            ${UPSTREAM}:${{ startsWith(github.ref, 'refs/tags/') && needs.test.outputs.relver || github.sha }}
 
       - uses: actions/download-artifact@v3
         with:
@@ -122,8 +155,6 @@ jobs:
         if: startsWith(github.ref, 'refs/tags/')
         uses: pypa/gh-action-pypi-publish@717ba43cfbb0387f6ce311b169a825772f54d295
         with:
-          # TODO: remove: needed to upload initial package manually to get scoped token
-          skip_existing: true
           user: __token__
           password: ${{ secrets.pypi }}
 
@@ -134,6 +165,6 @@ jobs:
           fail_on_unmatched_files: true
           files: dist/*
           body: |
-            PyPI: https://pypi.org/project/galactory/${{ needs.build.outputs.relver }}/
-            Container: `ghcr.io/${{ github.repository }}:${{ needs.build.outputs.relver }}`
+            PyPI: https://pypi.org/project/galactory/${{ needs.test.outputs.relver }}/
+            Container: `ghcr.io/${{ github.repository }}:${{ needs.test.outputs.relver }}`
             Browse container tags: https://github.com/briantist/galactory/pkgs/container/galactory