|
2 | 2 | # If you are looking for the tinygo/tinygo "release" Docker image please see |
3 | 3 | # https://github.com/tinygo-org/docker |
4 | 4 | # |
| 5 | +# The compiler image is built on top of an LLVM image. The LLVM image is built |
| 6 | +# only when the registry holds no image for the current LLVM version and build |
| 7 | +# recipe, so a change to TinyGo alone does not build LLVM again. An LLVM build |
| 8 | +# takes at least 1-2 hours. |
| 9 | +# |
| 10 | +# Use the manual trigger with force-llvm to build the LLVM image again. |
5 | 11 | name: Docker |
6 | 12 | on: |
7 | 13 | push: |
8 | | - branches: [ dev, fix-docker-llvm-build ] |
| 14 | + branches: [ dev ] |
| 15 | + workflow_dispatch: |
| 16 | + inputs: |
| 17 | + force-llvm: |
| 18 | + description: Build the LLVM image again |
| 19 | + type: boolean |
| 20 | + default: false |
9 | 21 |
|
10 | 22 | concurrency: |
11 | 23 | group: ${{ github.workflow }}-${{ github.ref }} |
12 | 24 | cancel-in-progress: true |
13 | 25 |
|
14 | 26 | jobs: |
| 27 | + llvm: |
| 28 | + name: build-push-llvm |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + packages: write |
| 32 | + contents: read |
| 33 | + outputs: |
| 34 | + image: ${{ steps.tag.outputs.image }} |
| 35 | + steps: |
| 36 | + - name: Free Disk space |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + df -h |
| 40 | + sudo rm -rf /opt/hostedtoolcache |
| 41 | + sudo rm -rf /usr/local/lib/android |
| 42 | + sudo rm -rf /usr/share/dotnet |
| 43 | + sudo rm -rf /opt/ghc |
| 44 | + sudo rm -rf /usr/local/graalvm |
| 45 | + sudo rm -rf /usr/local/share/boost |
| 46 | + df -h |
| 47 | + - name: Check out the repo |
| 48 | + uses: actions/checkout@v6 |
| 49 | + - name: Set up Docker Buildx |
| 50 | + uses: docker/setup-buildx-action@v4 |
| 51 | + - name: Log in to Github Container Registry |
| 52 | + uses: docker/login-action@v4 |
| 53 | + with: |
| 54 | + registry: ghcr.io |
| 55 | + username: ${{ github.actor }} |
| 56 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + - name: Get the image tag |
| 58 | + id: tag |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + tag=$(sh tools/llvm-image-tag.sh) |
| 62 | + echo "image=ghcr.io/${{ github.repository_owner }}/llvm-22:$tag" >> "$GITHUB_OUTPUT" |
| 63 | + - name: Look for the image |
| 64 | + id: check |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + if docker buildx imagetools inspect "${{ steps.tag.outputs.image }}" > /dev/null 2>&1; then |
| 68 | + echo "exists=true" >> "$GITHUB_OUTPUT" |
| 69 | + else |
| 70 | + echo "exists=false" >> "$GITHUB_OUTPUT" |
| 71 | + fi |
| 72 | + - name: Build and push |
| 73 | + if: steps.check.outputs.exists != 'true' || inputs.force-llvm |
| 74 | + uses: docker/build-push-action@v7 |
| 75 | + with: |
| 76 | + context: . |
| 77 | + file: Dockerfile.llvm |
| 78 | + push: true |
| 79 | + tags: ${{ steps.tag.outputs.image }} |
| 80 | + |
15 | 81 | push_to_registry: |
16 | 82 | name: build-push-dev |
| 83 | + needs: llvm |
17 | 84 | runs-on: ubuntu-latest |
18 | 85 | permissions: |
19 | 86 | packages: write |
|
62 | 129 | with: |
63 | 130 | context: . |
64 | 131 | push: true |
| 132 | + build-args: | |
| 133 | + LLVM_IMAGE=${{ needs.llvm.outputs.image }} |
65 | 134 | tags: ${{ steps.meta.outputs.tags }} |
66 | 135 | labels: ${{ steps.meta.outputs.labels }} |
67 | 136 | cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/tinygo-dev:buildcache |
68 | | - cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/tinygo-dev:buildcache,mode=max |
| 137 | + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/tinygo-dev:buildcache,mode=max,ignore-error=true |
0 commit comments