diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e43fa58d..2ad7f80ed 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -114,8 +114,10 @@ jobs: name: Publish the Docker image needs: - build-phar - if: github.event_name == 'release' steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: name: box-phar @@ -124,10 +126,10 @@ jobs: # See https://github.com/actions/download-artifact#limitations # the permissions are not guaranteed to be preserved - name: Ensure PHAR is executable - run: chmod 755 box.phar - - - name: Check that the PHAR works - run: ./box.phar --ansi --version + run: | + chmod 755 box.phar + mv -vf box.phar bin/box.phar + ./bin/box.phar --ansi --version - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -136,32 +138,53 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to Docker Container Registry + if: github.event_name == 'release' uses: docker/login-action@v2 with: username: ${{ env.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Setup the Docker (release) tag(s) + if: github.event_name == 'release' + run: | + echo "DOCKER_TAGS<<$EOF" >> $GITHUB_ENV + ${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }} >> $GITHUB_ENV + ${{ env.DOCKERHUB_USERNAME }}/box:latest >> $GITHUB_ENV + echo "$EOF" >> $GITHUB_ENV + echo "DOCKER_TEST_TAG=${{ env.DOCKERHUB_USERNAME }}/box:latest" >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + if: github.event_name != 'release' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup the Docker tag(s) + if: github.event_name != 'release' + run: | + echo "DOCKER_TAGS=ghcr.io/box-project/box" >> $GITHUB_ENV + echo "DOCKER_TEST_TAG=ghcr.io/box-project/box" >> $GITHUB_ENV + - name: Build and export to Docker uses: docker/build-push-action@v3 with: context: . file: ${{ env.DOCKERFILE }} platforms: linux/amd64 - tags: | - ${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }} - ${{ env.DOCKERHUB_USERNAME }}/box:latest + tags: ${{ env.DOCKER_TAGS }} load: true - - name: Test the image - run: docker run --rm ${{ env.DOCKERHUB_USERNAME }}/box:latest --version + - name: Test the (release) image + run: docker run --rm ${{ env.DOCKER_TEST_TAG }} --version - name: Build and push + if: github.event_name == 'release' uses: docker/build-push-action@v3 with: context: . file: ${{ env.DOCKERFILE }} platforms: linux/amd64 - tags: | - ${{ env.DOCKERHUB_USERNAME }}/box:${{ github.ref_name }} - ${{ env.DOCKERHUB_USERNAME }}/box:latest + tags: ${{ env.DOCKER_TAGS }} push: true