@@ -389,100 +389,6 @@ jobs:
389
389
with :
390
390
api-key : ${{ secrets.DATADOG_API_KEY }}
391
391
392
- deploy :
393
- name : " deploy"
394
- runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
395
- timeout-minutes : 30
396
- needs : changes
397
- if : |
398
- github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
399
- && needs.changes.outputs.docs-only == 'false'
400
- permissions :
401
- contents : read
402
- id-token : write
403
- steps :
404
- - name : Checkout
405
- uses : actions/checkout@v4
406
- with :
407
- fetch-depth : 0
408
-
409
- - name : Authenticate to Google Cloud
410
- uses : google-github-actions/auth@v1
411
- with :
412
- workload_identity_provider : projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
413
- service_account : coder-ci@coder-dogfood.iam.gserviceaccount.com
414
-
415
- - name : Set up Google Cloud SDK
416
- uses : google-github-actions/setup-gcloud@v1
417
-
418
- - name : Setup Node
419
- uses : ./.github/actions/setup-node
420
-
421
- - name : Setup Go
422
- uses : ./.github/actions/setup-go
423
-
424
- - name : Install goimports
425
- run : go install golang.org/x/tools/cmd/goimports@latest
426
- - name : Install nfpm
427
- run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
428
-
429
- - name : Install zstd
430
- run : sudo apt-get install -y zstd
431
-
432
- - name : Build Release
433
- run : |
434
- set -euo pipefail
435
- go mod download
436
-
437
- version="$(./scripts/version.sh)"
438
- make gen/mark-fresh
439
- make -j \
440
- build/coder_"$version"_windows_amd64.zip \
441
- build/coder_"$version"_linux_amd64.{tar.gz,deb}
442
-
443
- - name : Install Release
444
- run : |
445
- set -euo pipefail
446
-
447
- regions=(
448
- # gcp-region-id instance-name systemd-service-name
449
- "us-central1-a coder coder"
450
- "australia-southeast1-b coder-sydney coder-workspace-proxy"
451
- "europe-west3-c coder-europe coder-workspace-proxy"
452
- "southamerica-east1-b coder-brazil coder-workspace-proxy"
453
- )
454
-
455
- deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
456
- if [ ! -f "$deb_pkg" ]; then
457
- echo "deb package not found: $deb_pkg"
458
- ls -l ./build
459
- exit 1
460
- fi
461
-
462
- gcloud config set project coder-dogfood
463
- for region in "${regions[@]}"; do
464
- echo "::group::$region"
465
- set -- $region
466
-
467
- set -x
468
- gcloud config set compute/zone "$1"
469
- gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
470
- gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
471
- set +x
472
-
473
- echo "::endgroup::"
474
- done
475
-
476
- - name : Upload build artifacts
477
- uses : actions/upload-artifact@v3
478
- with :
479
- name : coder
480
- path : |
481
- ./build/*.zip
482
- ./build/*.tar.gz
483
- ./build/*.deb
484
- retention-days : 7
485
-
486
392
test-js :
487
393
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
488
394
needs : changes
@@ -722,9 +628,10 @@ jobs:
722
628
723
629
echo "Required checks have passed"
724
630
725
- build-main-image :
726
- # This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch.
727
- # We are only building this for amd64 plateform. (>95% pulls are for amd64)
631
+ build :
632
+ # This builds and publishes ghcr.io/coder/coder-preview:main for each commit
633
+ # to main branch. We are only building this for amd64 platform. (>95% pulls
634
+ # are for amd64)
728
635
needs : changes
729
636
if : github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
730
637
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
@@ -752,27 +659,34 @@ jobs:
752
659
username : ${{ github.actor }}
753
660
password : ${{ secrets.GITHUB_TOKEN }}
754
661
755
- - name : Build and push Linux amd64 Docker image
756
- id : build_and_push
662
+ - name : Build
757
663
run : |
758
664
set -euxo pipefail
759
665
go mod download
760
- make gen/mark-fresh
761
- export DOCKER_IMAGE_NO_PREREQUISITES=true
666
+
762
667
version="$(./scripts/version.sh)"
668
+ make gen/mark-fresh
669
+ make -j \
670
+ build/coder_linux_amd64 \
671
+ build/coder_"$version"_windows_amd64.zip \
672
+ build/coder_"$version"_linux_amd64.{tar.gz,deb}
673
+
674
+ - name : Build and Push Linux amd64 Docker Image
675
+ run : |
676
+ set -euxo pipefail
677
+ tag="main-$(echo "$version" | sed 's/+/-/g')"
678
+
763
679
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
764
- make -j build/coder_linux_amd64
765
680
./scripts/build_docker.sh \
766
681
--arch amd64 \
767
- --target ghcr.io/coder/coder-preview:main \
682
+ --target " ghcr.io/coder/coder-preview:$tag" \
768
683
--version $version \
769
684
--push \
770
685
build/coder_linux_amd64
771
686
772
- # Tag image with new package tag and push
773
- tag=$(echo "$version" | sed 's/+/-/g')
774
- docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag
775
- docker push ghcr.io/coder/coder-preview:main-$tag
687
+ # Tag as main
688
+ docker tag "ghcr.io/coder/coder-preview:$tag" ghcr.io/coder/coder-preview:main
689
+ docker push ghcr.io/coder/coder-preview:main
776
690
777
691
- name : Prune old images
778
692
uses : vlaurin/action-ghcr-prune@v0.5.0
@@ -784,3 +698,158 @@ jobs:
784
698
keep-tags-regexes : ^pr
785
699
prune-tags-regexes : ^main-
786
700
prune-untagged : true
701
+
702
+ - name : Upload build artifacts
703
+ uses : actions/upload-artifact@v3
704
+ with :
705
+ name : coder
706
+ path : |
707
+ ./build/*.zip
708
+ ./build/*.tar.gz
709
+ ./build/*.deb
710
+ retention-days : 7
711
+
712
+ deploy :
713
+ name : " deploy"
714
+ runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
715
+ timeout-minutes : 30
716
+ needs :
717
+ - changes
718
+ - build
719
+ if : |
720
+ github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
721
+ && needs.changes.outputs.docs-only == 'false'
722
+ permissions :
723
+ contents : read
724
+ id-token : write
725
+ steps :
726
+ - name : Checkout
727
+ uses : actions/checkout@v4
728
+ with :
729
+ fetch-depth : 0
730
+
731
+ - name : Authenticate to Google Cloud
732
+ uses : google-github-actions/auth@v1
733
+ with :
734
+ workload_identity_provider : projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
735
+ service_account : coder-ci@coder-dogfood.iam.gserviceaccount.com
736
+
737
+ - name : Set up Google Cloud SDK
738
+ uses : google-github-actions/setup-gcloud@v1
739
+
740
+ - name : Set up Flux CLI
741
+ uses : fluxcd/flux2/action@main
742
+
743
+ - name : Get Cluster Credentials
744
+ uses : " google-github-actions/get-gke-credentials@v1"
745
+ with :
746
+ cluster_name : dogfood-v2
747
+ location : us-central1-a
748
+ project_id : coder-dogfood-v2
749
+
750
+ - name : Reconcile Flux
751
+ run : |
752
+ set -euxo pipefail
753
+ flux --namespace flux-system reconcile source git flux-system
754
+ flux --namespace flux-system reconcile source git coder-main
755
+ flux --namespace flux-system reconcile kustomization flux-system
756
+ flux --namespace flux-system reconcile kustomization coder
757
+ flux --namespace flux-system reconcile source chart coder-coder
758
+ flux --namespace coder reconcile helmrelease coder
759
+
760
+ # Just updating Flux is usually not enough. The Helm release may get
761
+ # redeployed, but unless something causes the Deployment to update the
762
+ # pods won't be recreated. It's important that the pods get recreated,
763
+ # since we use `imagePullPolicy: Always` to ensure we're running the
764
+ # latest image.
765
+ - name : Rollout Deployment
766
+ run : |
767
+ set -euxo pipefail
768
+ kubectl --namespace coder rollout restart deployment/coder
769
+ kubectl --namespace coder rollout status deployment/coder
770
+
771
+ # TODO: when we remove this, instead of removing it we need to change it so it
772
+ # still upgrades workspace proxies which are not deployed on K8s
773
+ deploy-legacy :
774
+ name : " deploy-legacy"
775
+ runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
776
+ timeout-minutes : 30
777
+ needs : changes
778
+ if : |
779
+ github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
780
+ && needs.changes.outputs.docs-only == 'false'
781
+ permissions :
782
+ contents : read
783
+ id-token : write
784
+ steps :
785
+ - name : Checkout
786
+ uses : actions/checkout@v4
787
+ with :
788
+ fetch-depth : 0
789
+
790
+ - name : Authenticate to Google Cloud
791
+ uses : google-github-actions/auth@v1
792
+ with :
793
+ workload_identity_provider : projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
794
+ service_account : coder-ci@coder-dogfood.iam.gserviceaccount.com
795
+
796
+ - name : Set up Google Cloud SDK
797
+ uses : google-github-actions/setup-gcloud@v1
798
+
799
+ - name : Setup Node
800
+ uses : ./.github/actions/setup-node
801
+
802
+ - name : Setup Go
803
+ uses : ./.github/actions/setup-go
804
+
805
+ - name : Install goimports
806
+ run : go install golang.org/x/tools/cmd/goimports@latest
807
+ - name : Install nfpm
808
+ run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
809
+
810
+ - name : Install zstd
811
+ run : sudo apt-get install -y zstd
812
+
813
+ - name : Build Release
814
+ run : |
815
+ set -euo pipefail
816
+ go mod download
817
+
818
+ version="$(./scripts/version.sh)"
819
+ make gen/mark-fresh
820
+ make -j \
821
+ build/coder_"$version"_windows_amd64.zip \
822
+ build/coder_"$version"_linux_amd64.{tar.gz,deb}
823
+
824
+ - name : Install Release
825
+ run : |
826
+ set -euo pipefail
827
+
828
+ regions=(
829
+ # gcp-region-id instance-name systemd-service-name
830
+ "us-central1-a coder coder"
831
+ "australia-southeast1-b coder-sydney coder-workspace-proxy"
832
+ "europe-west3-c coder-europe coder-workspace-proxy"
833
+ "southamerica-east1-b coder-brazil coder-workspace-proxy"
834
+ )
835
+
836
+ deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
837
+ if [ ! -f "$deb_pkg" ]; then
838
+ echo "deb package not found: $deb_pkg"
839
+ ls -l ./build
840
+ exit 1
841
+ fi
842
+
843
+ gcloud config set project coder-dogfood
844
+ for region in "${regions[@]}"; do
845
+ echo "::group::$region"
846
+ set -- $region
847
+
848
+ set -x
849
+ gcloud config set compute/zone "$1"
850
+ gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
851
+ gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
852
+ set +x
853
+
854
+ echo "::endgroup::"
855
+ done
0 commit comments