11name : Deploy artifacts
22
33on :
4- push :
5- branches :
6- - main
4+ workflow_call :
5+ inputs :
6+ deploy-channel :
7+ required : true
8+ type : string
9+ secrets :
10+ artifact-registry-uploader-json-creds :
11+ required : true
712
813permissions :
914 contents : read
1015
1116jobs :
17+ set-variables :
18+ runs-on : ubuntu-24.04
19+ outputs :
20+ version : ${{ steps.define-version.outputs.version }}
21+ steps :
22+ - name : Define version
23+ id : define-version
24+ run : |
25+ TIME=$(date -u +'%Y%m%d%H%M')
26+ # TODO(b/440196950): Setup condition for stable channel.
27+ case "${{ inputs.deploy-channel }}" in
28+ unstable)
29+ # Unstable version format : X.Y-gitYYYYMMDDHHMM-<Github SHA 8 digit>
30+ SEMVER=$(echo ${{ github.ref_name }} | grep -oE '[0-9]+.[0-9]+')
31+ SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
32+ VERSION="${SEMVER}-git${TIME}-${SHORT_SHA}"
33+ ;;
34+ nightly)
35+ # Nightly version format : gitYYYYMMDDHHMM-<Github SHA 8 digit>
36+ SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
37+ VERSION="git${TIME}-${SHORT_SHA}"
38+ ;;
39+ *)
40+ exit 1
41+ ;;
42+ esac
43+ echo "version=$VERSION" >> $GITHUB_OUTPUT
44+ echo "Version is $VERSION"
45+
1246 deploy-cuttlefish-cvdremote-amd64-debian-package :
13- if : github.repository_owner == 'google'
47+ needs : [set-variables]
1448 environment : deployment
1549 runs-on : ubuntu-24.04
1650 container :
@@ -20,19 +54,21 @@ jobs:
2054 uses : actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 # aka v2
2155 - name : Build debian package cuttlefish-cvdremote
2256 uses : ./.github/actions/build-cuttlefish-cvdremote-debian-package
57+ with :
58+ version : ${{ needs.set-variables.outputs.version }}
2359 - name : Get exact filename
2460 run : echo "path=$(find . -name cuttlefish-cvdremote_*.deb)" >> $GITHUB_ENV
2561 - name : Authentication on GCP project android-cuttlefish-artifacts
2662 uses : ' google-github-actions/auth@v2'
2763 with :
28- credentials_json : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
64+ credentials_json : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
2965 - name : Deploy debian package cuttlefish-cvdremote
3066 uses : ./.github/actions/deploy-cuttlefish-cvdremote-debian-package
3167 with :
3268 path : ${{ env.path }}
3369
3470 deploy-cuttlefish-cvdremote-arm64-debian-package :
35- if : github.repository_owner == 'google'
71+ needs : [set-variables]
3672 environment : deployment
3773 runs-on : ubuntu-24.04-arm
3874 container :
@@ -42,19 +78,21 @@ jobs:
4278 uses : actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 # aka v2
4379 - name : Build debian package cuttlefish-cvdremote
4480 uses : ./.github/actions/build-cuttlefish-cvdremote-debian-package
81+ with :
82+ version : ${{ needs.set-variables.outputs.version }}
4583 - name : Get exact filename
4684 run : echo "path=$(find . -name cuttlefish-cvdremote_*.deb)" >> $GITHUB_ENV
4785 - name : Authentication on GCP project android-cuttlefish-artifacts
4886 uses : ' google-github-actions/auth@v2'
4987 with :
50- credentials_json : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
88+ credentials_json : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
5189 - name : Deploy debian package cuttlefish-cvdremote
5290 uses : ./.github/actions/deploy-cuttlefish-cvdremote-debian-package
5391 with :
5492 path : ${{ env.path }}
5593
5694 deploy-cuttlefish-cloud-orchestrator-amd64-docker-image :
57- if : github.repository_owner == 'google'
95+ needs : [set-variables]
5896 environment : deployment
5997 runs-on : ubuntu-24.04
6098 steps :
@@ -65,20 +103,21 @@ jobs:
65103 - name : Authentication on GCP project android-cuttlefish-artifacts
66104 uses : ' google-github-actions/auth@v2'
67105 with :
68- credentials_json : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
106+ credentials_json : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
69107 - name : Login to Artifact Registry
70108 uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # aka v3.5.0
71109 with :
72110 registry : us-docker.pkg.dev
73111 username : _json_key
74- password : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
112+ password : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
75113 - name : Deploy docker image
76114 uses : ./.github/actions/deploy-cuttlefish-cloud-orchestrator-docker-image
77115 with :
78116 arch : amd64
117+ version : ${{ needs.set-variables.outputs.version }}
79118
80119 deploy-cuttlefish-cloud-orchestrator-arm64-docker-image :
81- if : github.repository_owner == 'google'
120+ needs : [set-variables]
82121 environment : deployment
83122 runs-on : ubuntu-24.04-arm
84123 steps :
@@ -89,21 +128,21 @@ jobs:
89128 - name : Authentication on GCP project android-cuttlefish-artifacts
90129 uses : ' google-github-actions/auth@v2'
91130 with :
92- credentials_json : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
131+ credentials_json : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
93132 - name : Login to Artifact Registry
94133 uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # aka v3.5.0
95134 with :
96135 registry : us-docker.pkg.dev
97136 username : _json_key
98- password : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
137+ password : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
99138 - name : Deploy docker image
100139 uses : ./.github/actions/deploy-cuttlefish-cloud-orchestrator-docker-image
101140 with :
102141 arch : arm64
142+ version : ${{ needs.set-variables.outputs.version }}
103143
104144 deploy-cuttlefish-cloud-orchestrator-docker-manifest :
105- if : github.repository_owner == 'google'
106- needs : [deploy-cuttlefish-cloud-orchestrator-amd64-docker-image, deploy-cuttlefish-cloud-orchestrator-arm64-docker-image]
145+ needs : [deploy-cuttlefish-cloud-orchestrator-amd64-docker-image, deploy-cuttlefish-cloud-orchestrator-arm64-docker-image, set-variables]
107146 environment : deployment
108147 runs-on : ubuntu-24.04
109148 steps :
@@ -112,28 +151,19 @@ jobs:
112151 - name : Authentication on GCP project android-cuttlefish-artifacts
113152 uses : ' google-github-actions/auth@v2'
114153 with :
115- credentials_json : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
154+ credentials_json : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
116155 - name : Login to Artifact Registry
117156 uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # aka v3.5.0
118157 with :
119158 registry : us-docker.pkg.dev
120159 username : _json_key
121- password : ' ${{ secrets.ARTIFACT_REGISTRY_UPLOADER }}'
160+ password : ' ${{ secrets.artifact-registry-uploader-json-creds }}'
122161 - name : Deploy manifests
123162 run : |
124- # TODO(b/440196950): Setup condition on this step when we build
125- # stable/unstable versions here too.
126-
127- # Stable/Unstable version tag : X.Y.Z
128- # Nightly version tag : gitYYYYMMDD-<Github SHA 8 digit>
129- DATE=$(date -u +'%Y%m%d')
130- SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-8)
131- TAG="git${DATE}-${SHORT_SHA}"
132- IMAGE=us-docker.pkg.dev/android-cuttlefish-artifacts/cuttlefish-orchestration/cuttlefish-cloud-orchestrator
133-
134- for MANIFEST_TAG in ${TAG} nightly; do
163+ VERSION=${{ needs.set-variables.outputs.version }}
164+ for MANIFEST_TAG in ${VERSION} ${{ inputs.deploy-channel }}; do
135165 docker manifest create ${IMAGE}:${MANIFEST_TAG} \
136- --amend ${IMAGE}:${TAG }-amd64 \
137- --amend ${IMAGE}:${TAG }-arm64
166+ --amend ${IMAGE}:${VERSION }-amd64 \
167+ --amend ${IMAGE}:${VERSION }-arm64
138168 docker manifest push ${IMAGE}:${MANIFEST_TAG}
139169 done
0 commit comments