@@ -655,7 +655,7 @@ jobs:
655
655
# to main branch. We are only building this for amd64 platform. (>95% pulls
656
656
# are for amd64)
657
657
needs : changes
658
- if : github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
658
+ if : needs.changes.outputs.docs-only == 'false' && !github.event.pull_request.head.repo.fork
659
659
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
660
660
env :
661
661
DOCKER_CLI_EXPERIMENTAL : " enabled"
@@ -692,46 +692,70 @@ jobs:
692
692
go mod download
693
693
694
694
version="$(./scripts/version.sh)"
695
+ tag="main-$(echo "$version" | sed 's/+/-/g')"
696
+ echo "tag=$tag" >> $GITHUB_OUTPUT
697
+
695
698
make gen/mark-fresh
696
699
make -j \
697
- build/coder_linux_amd64 \
700
+ build/coder_linux_{amd64,arm64,armv7} \
698
701
build/coder_"$version"_windows_amd64.zip \
699
702
build/coder_"$version"_linux_amd64.{tar.gz,deb}
700
703
701
- - name : Build and Push Linux amd64 Docker Image
704
+ - name : Build Linux Docker images
702
705
id : build-docker
706
+ env :
707
+ CODER_IMAGE_BASE : ghcr.io/coder/coder-preview
708
+ CODER_IMAGE_TAG_PREFIX : main
709
+ DOCKER_CLI_EXPERIMENTAL : " enabled"
703
710
run : |
704
711
set -euxo pipefail
712
+
713
+ # build Docker images for each architecture
705
714
version="$(./scripts/version.sh)"
706
715
tag="main-$(echo "$version" | sed 's/+/-/g')"
707
-
708
- export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
709
- ./scripts/build_docker.sh \
710
- --arch amd64 \
711
- --target "ghcr.io/coder/coder-preview:$tag" \
712
- --version $version \
713
- --push \
714
- build/coder_linux_amd64
715
-
716
- # Tag as main
717
- docker tag "ghcr.io/coder/coder-preview:$tag" ghcr.io/coder/coder-preview:main
718
- docker push ghcr.io/coder/coder-preview:main
719
-
720
- # Store the tag in an output variable so we can use it in other jobs
721
716
echo "tag=$tag" >> $GITHUB_OUTPUT
722
717
718
+ # build images for each architecture
719
+ make -j build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
720
+
721
+ # only push if we are on main branch
722
+ if [ "${{ github.ref }}" == "refs/heads/main" ]; then
723
+ # build and push multi-arch manifest, this depends on the other images
724
+ # being pushed so will automatically push them
725
+ make -j push/build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
726
+
727
+ # Define specific tags
728
+ tags=("$tag" "main" "latest")
729
+
730
+ # Create and push a multi-arch manifest for each tag
731
+ # we are adding `latest` tag and keeping `main` for backward
732
+ # compatibality
733
+ for t in "${tags[@]}"; do
734
+ ./scripts/build_docker_multiarch.sh \
735
+ --push \
736
+ --target "ghcr.io/coder/coder-preview:$t" \
737
+ --version $version \
738
+ $(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag)
739
+ done
740
+ fi
741
+
723
742
- name : Prune old images
743
+ if : github.ref == 'refs/heads/main'
724
744
uses : vlaurin/action-ghcr-prune@v0.5.0
725
745
with :
726
746
token : ${{ secrets.GITHUB_TOKEN }}
727
747
organization : coder
728
748
container : coder-preview
729
749
keep-younger-than : 7 # days
750
+ keep-tags : latest
730
751
keep-tags-regexes : ^pr
731
- prune-tags-regexes : ^main-
752
+ prune-tags-regexes : |
753
+ ^main-
754
+ ^v
732
755
prune-untagged : true
733
756
734
757
- name : Upload build artifacts
758
+ if : github.ref == 'refs/heads/main'
735
759
uses : actions/upload-artifact@v4
736
760
with :
737
761
name : coder
0 commit comments