4
4
push :
5
5
branches :
6
6
-main
7
+ -release/*
7
8
8
9
pull_request :
9
10
workflow_dispatch :
@@ -919,6 +920,7 @@ jobs:
919
920
required :
920
921
runs-on :ubuntu-latest
921
922
needs :
923
+ -changes
922
924
-fmt
923
925
-lint
924
926
-gen
@@ -942,6 +944,7 @@ jobs:
942
944
-name :Ensure required checks
943
945
run :|# zizmor: ignore[template-injection] We're just reading needs.x.result here, no risk of injection
944
946
echo "Checking required checks"
947
+ echo "- changes: ${{ needs.changes.result }}"
945
948
echo "- fmt: ${{ needs.fmt.result }}"
946
949
echo "- lint: ${{ needs.lint.result }}"
947
950
echo "- gen: ${{ needs.gen.result }}"
@@ -967,7 +970,7 @@ jobs:
967
970
needs :changes
968
971
# We always build the dylibs on Go changes to verify we're not merging unbuildable code,
969
972
# but they need only be signed and uploaded on coder/coder main.
970
- if :needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
973
+ if :needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
971
974
runs-on :${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest' }}
972
975
steps :
973
976
# Harden Runner doesn't work on macOS
@@ -995,7 +998,7 @@ jobs:
995
998
uses :./.github/actions/setup-go
996
999
997
1000
-name :Install rcodesign
998
- if :${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
1001
+ if :${{ github.repository_owner == 'coder' &&( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}
999
1002
run :|
1000
1003
set -euo pipefail
1001
1004
wget -O /tmp/rcodesign.tar.gz https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.22.0/apple-codesign-0.22.0-macos-universal.tar.gz
@@ -1006,7 +1009,7 @@ jobs:
1006
1009
rm /tmp/rcodesign.tar.gz
1007
1010
1008
1011
-name :Setup Apple Developer certificate and API key
1009
- if :${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
1012
+ if :${{ github.repository_owner == 'coder' &&( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}
1010
1013
run :|
1011
1014
set -euo pipefail
1012
1015
touch /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
@@ -1027,12 +1030,12 @@ jobs:
1027
1030
make gen/mark-fresh
1028
1031
make build/coder-dylib
1029
1032
env :
1030
- CODER_SIGN_DARWIN :${{ github.ref == 'refs/heads/main' && '1' || '0' }}
1033
+ CODER_SIGN_DARWIN :${{( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && '1' || '0' }}
1031
1034
AC_CERTIFICATE_FILE :/tmp/apple_cert.p12
1032
1035
AC_CERTIFICATE_PASSWORD_FILE :/tmp/apple_cert_password.txt
1033
1036
1034
1037
-name :Upload build artifacts
1035
- if :${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
1038
+ if :${{ github.repository_owner == 'coder' &&( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}
1036
1039
uses :actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
1037
1040
with :
1038
1041
name :dylibs
@@ -1042,7 +1045,7 @@ jobs:
1042
1045
retention-days :7
1043
1046
1044
1047
-name :Delete Apple Developer certificate and API key
1045
- if :${{ github.repository_owner == 'coder' && github.ref == 'refs/heads/main' }}
1048
+ if :${{ github.repository_owner == 'coder' &&( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}
1046
1049
run :rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8}
1047
1050
1048
1051
check-build :
@@ -1092,7 +1095,7 @@ jobs:
1092
1095
needs :
1093
1096
-changes
1094
1097
-build-dylib
1095
- if :github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' && !github.event.pull_request.head.repo.fork
1098
+ if :( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && needs.changes.outputs.docs-only == 'false' && !github.event.pull_request.head.repo.fork
1096
1099
runs-on :${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-22.04' }}
1097
1100
permissions :
1098
1101
# Necessary to push docker images to ghcr.io.
@@ -1245,40 +1248,45 @@ jobs:
1245
1248
id :build-docker
1246
1249
env :
1247
1250
CODER_IMAGE_BASE :ghcr.io/coder/coder-preview
1248
- CODER_IMAGE_TAG_PREFIX :main
1249
1251
DOCKER_CLI_EXPERIMENTAL :" enabled"
1250
1252
run :|
1251
1253
set -euxo pipefail
1252
1254
1253
1255
# build Docker images for each architecture
1254
1256
version="$(./scripts/version.sh)"
1255
- tag="main- ${version//+/-}"
1257
+ tag="${version//+/-}"
1256
1258
echo "tag=$tag" >> "$GITHUB_OUTPUT"
1257
1259
1258
1260
# build images for each architecture
1259
1261
# note: omitting the -j argument to avoid race conditions when pushing
1260
1262
make build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
1261
1263
1262
- # only push if we are on main branch
1263
- if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
1264
+ # only push if we are on main branch or release branch
1265
+ if [[ "${GITHUB_REF}" == "refs/heads/main"|| "${GITHUB_REF}" == refs/heads/release/* ] ]; then
1264
1266
# build and push multi-arch manifest, this depends on the other images
1265
1267
# being pushed so will automatically push them
1266
1268
# note: omitting the -j argument to avoid race conditions when pushing
1267
1269
make push/build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
1268
1270
1269
1271
# Define specific tags
1270
- tags=("$tag" "main" "latest")
1272
+ tags=("$tag")
1273
+ if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
1274
+ tags+=("main" "latest")
1275
+ elif [[ "${GITHUB_REF}" == refs/heads/release/* ]]; then
1276
+ tags+=("release-${GITHUB_REF#refs/heads/release/}")
1277
+ fi
1271
1278
1272
1279
# Create and push a multi-arch manifest for each tag
1273
1280
# we are adding `latest` tag and keeping `main` for backward
1274
1281
# compatibality
1275
1282
for t in "${tags[@]}"; do
1276
- # shellcheck disable=SC2046
1277
- ./scripts/build_docker_multiarch.sh \
1278
- --push \
1279
- --target "ghcr.io/coder/coder-preview:$t" \
1280
- --version "$version" \
1281
- $(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag)
1283
+ echo "Pushing multi-arch manifest for tag: $t"
1284
+ # shellcheck disable=SC2046
1285
+ ./scripts/build_docker_multiarch.sh \
1286
+ --push \
1287
+ --target "ghcr.io/coder/coder-preview:$t" \
1288
+ --version "$version" \
1289
+ $(cat build/coder_"$version"_linux_{amd64,arm64,armv7}.tag)
1282
1290
done
1283
1291
fi
1284
1292
@@ -1469,112 +1477,28 @@ jobs:
1469
1477
./build/*.deb
1470
1478
retention-days :7
1471
1479
1480
+ # Deploy is handled in deploy.yaml so we can apply concurrency limits.
1472
1481
deploy :
1473
- name :" deploy"
1474
- runs-on :ubuntu-latest
1475
- timeout-minutes :30
1476
1482
needs :
1477
1483
-changes
1478
1484
-build
1479
1485
if :|
1480
- github.ref == 'refs/heads/main'&& ! github.event.pull_request.head.repo.fork
1486
+ ( github.ref == 'refs/heads/main'|| startsWith( github.ref, 'refs/heads/release/'))
1481
1487
&& needs.changes.outputs.docs-only == 'false'
1488
+ && !github.event.pull_request.head.repo.fork
1489
+ uses :./.github/workflows/deploy.yaml
1490
+ with :
1491
+ image :${{ needs.build.outputs.IMAGE }}
1482
1492
permissions :
1483
1493
contents :read
1484
1494
id-token :write
1485
- steps :
1486
- -name :Harden Runner
1487
- uses :step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
1488
- with :
1489
- egress-policy :audit
1490
-
1491
- -name :Checkout
1492
- uses :actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1493
- with :
1494
- fetch-depth :0
1495
- persist-credentials :false
1496
-
1497
- -name :Authenticate to Google Cloud
1498
- uses :google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
1499
- with :
1500
- workload_identity_provider :${{ vars.GCP_WORKLOAD_ID_PROVIDER }}
1501
- service_account :${{ vars.GCP_SERVICE_ACCOUNT }}
1502
-
1503
- -name :Set up Google Cloud SDK
1504
- uses :google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1
1505
-
1506
- -name :Set up Flux CLI
1507
- uses :fluxcd/flux2/action@6bf37f6a560fd84982d67f853162e4b3c2235edb # v2.6.4
1508
- with :
1509
- # Keep this and the github action up to date with the version of flux installed in dogfood cluster
1510
- version :" 2.5.1"
1511
-
1512
- -name :Get Cluster Credentials
1513
- uses :google-github-actions/get-gke-credentials@3da1e46a907576cefaa90c484278bb5b259dd395 # v3.0.0
1514
- with :
1515
- cluster_name :dogfood-v2
1516
- location :us-central1-a
1517
- project_id :coder-dogfood-v2
1518
-
1519
- -name :Reconcile Flux
1520
- run :|
1521
- set -euxo pipefail
1522
- flux --namespace flux-system reconcile source git flux-system
1523
- flux --namespace flux-system reconcile source git coder-main
1524
- flux --namespace flux-system reconcile kustomization flux-system
1525
- flux --namespace flux-system reconcile kustomization coder
1526
- flux --namespace flux-system reconcile source chart coder-coder
1527
- flux --namespace flux-system reconcile source chart coder-coder-provisioner
1528
- flux --namespace coder reconcile helmrelease coder
1529
- flux --namespace coder reconcile helmrelease coder-provisioner
1530
-
1531
- # Just updating Flux is usually not enough. The Helm release may get
1532
- # redeployed, but unless something causes the Deployment to update the
1533
- # pods won't be recreated. It's important that the pods get recreated,
1534
- # since we use `imagePullPolicy: Always` to ensure we're running the
1535
- # latest image.
1536
- -name :Rollout Deployment
1537
- run :|
1538
- set -euxo pipefail
1539
- kubectl --namespace coder rollout restart deployment/coder
1540
- kubectl --namespace coder rollout status deployment/coder
1541
- kubectl --namespace coder rollout restart deployment/coder-provisioner
1542
- kubectl --namespace coder rollout status deployment/coder-provisioner
1543
- kubectl --namespace coder rollout restart deployment/coder-provisioner-tagged
1544
- kubectl --namespace coder rollout status deployment/coder-provisioner-tagged
1545
-
1546
- deploy-wsproxies :
1547
- runs-on :ubuntu-latest
1548
- needs :build
1549
- if :github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
1550
- steps :
1551
- -name :Harden Runner
1552
- uses :step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
1553
- with :
1554
- egress-policy :audit
1555
-
1556
- -name :Checkout
1557
- uses :actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1558
- with :
1559
- fetch-depth :0
1560
- persist-credentials :false
1561
-
1562
- -name :Setup flyctl
1563
- uses :superfly/flyctl-actions/setup-flyctl@fc53c09e1bc3be6f54706524e3b82c4f462f77be # v1.5
1564
-
1565
- -name :Deploy workspace proxies
1566
- run :|
1567
- flyctl deploy --image "$IMAGE" --app paris-coder --config ./.github/fly-wsproxies/paris-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_PARIS" --yes
1568
- flyctl deploy --image "$IMAGE" --app sydney-coder --config ./.github/fly-wsproxies/sydney-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_SYDNEY" --yes
1569
- flyctl deploy --image "$IMAGE" --app sao-paulo-coder --config ./.github/fly-wsproxies/sao-paulo-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_SAO_PAULO" --yes
1570
- flyctl deploy --image "$IMAGE" --app jnb-coder --config ./.github/fly-wsproxies/jnb-coder.toml --env "CODER_PROXY_SESSION_TOKEN=$TOKEN_JNB" --yes
1571
- env :
1572
- FLY_API_TOKEN :${{ secrets.FLY_API_TOKEN }}
1573
- IMAGE :${{ needs.build.outputs.IMAGE }}
1574
- TOKEN_PARIS :${{ secrets.FLY_PARIS_CODER_PROXY_SESSION_TOKEN }}
1575
- TOKEN_SYDNEY :${{ secrets.FLY_SYDNEY_CODER_PROXY_SESSION_TOKEN }}
1576
- TOKEN_SAO_PAULO :${{ secrets.FLY_SAO_PAULO_CODER_PROXY_SESSION_TOKEN }}
1577
- TOKEN_JNB :${{ secrets.FLY_JNB_CODER_PROXY_SESSION_TOKEN }}
1495
+ packages :write # to retag image as dogfood
1496
+ secrets :
1497
+ FLY_API_TOKEN :${{ secrets.FLY_API_TOKEN }}
1498
+ FLY_PARIS_CODER_PROXY_SESSION_TOKEN :${{ secrets.FLY_PARIS_CODER_PROXY_SESSION_TOKEN }}
1499
+ FLY_SYDNEY_CODER_PROXY_SESSION_TOKEN :${{ secrets.FLY_SYDNEY_CODER_PROXY_SESSION_TOKEN }}
1500
+ FLY_SAO_PAULO_CODER_PROXY_SESSION_TOKEN :${{ secrets.FLY_SAO_PAULO_CODER_PROXY_SESSION_TOKEN }}
1501
+ FLY_JNB_CODER_PROXY_SESSION_TOKEN :${{ secrets.FLY_JNB_CODER_PROXY_SESSION_TOKEN }}
1578
1502
1579
1503
# sqlc-vet runs a postgres docker container, runs Coder migrations, and then
1580
1504
# runs sqlc-vet to ensure all queries are valid. This catches any mistakes