Fix build scripts #328
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker Image | |
on: | |
push: | |
branches: | |
- '**' | |
tags: | |
- '**' | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
amd64_build: | |
name: Build AMD64 Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build and export | |
id: build | |
if: startsWith(github.ref, 'refs/heads/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
outputs: type=image,push=true | |
- name: Replace tag without `v` | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/github-script@v6 | |
id: version | |
with: | |
script: | | |
return context.payload.ref.replace(/\/?refs\/tags\/v/, '') | |
result-encoding: string | |
- name: Build release and export | |
id: build_rel | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:${{steps.version.outputs.result}} | |
outputs: type=image,push=true | |
- name: Save digest | |
if: startsWith(github.ref, 'refs/heads/') | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Save release digest | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_amd64 | |
path: /tmp/digest.txt | |
x86_build: | |
name: Build x86 Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build and export | |
id: build | |
if: startsWith(github.ref, 'refs/heads/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/386 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
outputs: type=image,push=true | |
- name: Replace tag without `v` | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/github-script@v6 | |
id: version | |
with: | |
script: | | |
return context.payload.ref.replace(/\/?refs\/tags\/v/, '') | |
result-encoding: string | |
- name: Build release and export | |
id: build_rel | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/386 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:${{steps.version.outputs.result}} | |
outputs: type=image,push=true | |
- name: Save digest | |
if: startsWith(github.ref, 'refs/heads/') | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Save release digest | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_386 | |
path: /tmp/digest.txt | |
armv7_build: | |
name: Build ARMv7 Image | |
runs-on: [self-hosted, linux, ARM] | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build and export | |
id: build | |
if: startsWith(github.ref, 'refs/heads/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/arm/v7 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
THREADS=4 | |
outputs: type=image,push=true | |
- name: Replace tag without `v` | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/github-script@v6 | |
id: version | |
with: | |
script: | | |
return context.payload.ref.replace(/\/?refs\/tags\/v/, '') | |
result-encoding: string | |
- name: Build release and export | |
id: build_rel | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/arm/v7 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:${{steps.version.outputs.result}} | |
build-args: | | |
THREADS=4 | |
outputs: type=image,push=true | |
- name: Save digest | |
if: startsWith(github.ref, 'refs/heads/') | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Save release digest | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_armv7 | |
path: /tmp/digest.txt | |
arm64_build: | |
name: Build ARM64 Image | |
runs-on: [self-hosted, linux, ARM64] | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get commit SHA | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build and export | |
id: build | |
if: startsWith(github.ref, 'refs/heads/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/arm64 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:latest | |
build-args: | | |
SHA=${{ steps.vars.outputs.sha_short }} | |
THREADS=4 | |
outputs: type=image,push=true | |
- name: Replace tag without `v` | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/github-script@v6 | |
id: version | |
with: | |
script: | | |
return context.payload.ref.replace(/\/?refs\/tags\/v/, '') | |
result-encoding: string | |
- name: Build release and export | |
id: build_rel | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/arm64 | |
context: . | |
file: scripts/Dockerfile | |
tags: tindy2013/subconverter:${{steps.version.outputs.result}} | |
build-args: | | |
THREADS=4 | |
outputs: type=image,push=true | |
- name: Save digest | |
if: startsWith(github.ref, 'refs/heads/') | |
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt | |
- name: Save release digest | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digest_arm64 | |
path: /tmp/digest.txt | |
build: | |
name: Build | |
needs: [amd64_build, x86_build, armv7_build, arm64_build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout base | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
config-inline: | | |
[worker.oci] | |
max-parallelism = 1 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
path: /tmp/images/ | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Replace tag without `v` | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/github-script@v6 | |
id: version | |
with: | |
script: | | |
return context.payload.ref.replace(/\/?refs\/tags\/v/, '') | |
result-encoding: string | |
- name: Merge and push manifest on push | |
if: startsWith(github.ref, 'refs/heads/') | |
run: python scripts/merge_manifest.py | |
- name: Merge and push manifest on release | |
if: startsWith(github.ref, 'refs/tags/') | |
run: python scripts/merge_manifest.py ${{steps.version.outputs.result}} |