diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d66f0e7..83221f6 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -3,10 +3,26 @@ on: push: branches: - main + tags: + - "v*" +env: + IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') && 'true' || 'false' }} jobs: - release: + build: runs-on: ubuntu-latest + strategy: + matrix: + platform: [linux/amd64,linux/arm64] + env: + IS_LINUX: ${{ startsWith(matrix.platform, 'linux/') && 'true' || 'false' }} + GIT_TAG: ${{ needs.git-version.outputs.git_tag }} steps: + - + name: Sanitize platform name + id: set-platform + run: | + PLATFORM=$(echo ${{ matrix.platform }} | tr '/' '_') + echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -20,13 +36,39 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + name: Build Binaries id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: push: true - platforms: linux/amd64,linux/arm64 - tags: damillora/shioriko:latest + platforms: ${{ matrix.platform }} + outputs: | + type=local,dest=./output/${{ env.PLATFORM }} + - + name: Upload Binaries + uses: actions/upload-artifact@v4 + with: + name: shioriko-${{ env.PLATFORM }} + path: ./output + retention-days: 7 + - + name: Build and push (No tag) + if: env.IS_LINUX == 'true' && env.IS_RELEASE == 'false' + id: docker_build + uses: docker/build-push-action@v6 + with: + push: true + platforms: ${{ matrix.platform }} + tags: damillora/shioriko:main + - + name: Build and push (Tagged) + if: env.IS_LINUX == 'true' && env.IS_RELEASE == 'true' + id: docker_build + uses: docker/build-push-action@v6 + with: + push: true + platforms: ${{ matrix.platform }} + tags: damillora/shioriko:${{ env.GIT_TAG }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}