Skip to content

Commit 561c0a4

Browse files
authored
feat(github-workflow): upload dev binaries to artifact buckets (#5031)
* feat(github-workflow): upload dev binaries to gcs artifact bucket Signed-off-by: Abhradeep Chakraborty <abhradeep@dragonflydb.io>
1 parent fc00f2c commit 561c0a4

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/docker-dev-release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ jobs:
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4747
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
4848

49+
- name: Authenticate to Google Cloud
50+
uses: google-github-actions/auth@v2
51+
with:
52+
credentials_json: ${{ secrets.GCP_SA_KEY }}
53+
4954
- name: Get Build Information
5055
id: build_info
5156
run: |
@@ -98,6 +103,47 @@ jobs:
98103
docker stop $(docker ps -q --filter ancestor=${image_tag})
99104
done
100105
106+
- name: Extract and Upload Binaries
107+
if: matrix.flavor == 'ubuntu' # Only run once per flavor
108+
run: |
109+
# Get the image tag
110+
image_tags=(${{ steps.metadata.outputs.tags }})
111+
image_tag=${image_tags[0]}
112+
113+
# Extract version from the image
114+
echo "Extracting version from image..."
115+
VERSION=$(docker run --rm ${image_tag} dragonfly --version | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | head -n1 | cut -d' ' -f2 | cut -d'-' -f1)
116+
# Check if version starts with a release version (v*.*.*)
117+
if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
118+
# Get the latest release version to use as prefix
119+
LATEST_RELEASE=$(curl -s https://api.github.com/repos/dragonflydb/dragonfly/releases/latest | jq -r .tag_name)
120+
VERSION="${LATEST_RELEASE}+${VERSION}"
121+
fi
122+
echo "Dragonfly version: $VERSION"
123+
124+
echo "Extracting binary from ${image_tag} for ${{ matrix.os.arch }}"
125+
126+
# Create a temporary container and copy the binary
127+
container_id=$(docker create ${image_tag})
128+
docker cp ${container_id}:/usr/local/bin/dragonfly ./dragonfly
129+
docker rm ${container_id}
130+
131+
# Create a tar archive
132+
if [[ "${{ matrix.os.arch }}" == "arm64" ]]; then
133+
arch_name="aarch64"
134+
else
135+
arch_name="x86_64"
136+
fi
137+
tar_name="dragonfly-${arch_name}-dbgsym.tar.gz"
138+
tar czf ${tar_name} dragonfly
139+
140+
# Upload to GCS
141+
echo "Uploading ${tar_name} to GCS"
142+
gcloud storage cp "$tar_name" "gs://${{ secrets.ARTIFACT_BUCKET }}/dragonfly/$VERSION/$tar_name"
143+
144+
# Cleanup
145+
rm -f dragonfly ${tar_name}
146+
101147
outputs:
102148
# matrix jobs outputs override each other, but we use the same sha
103149
# for all images, so we can use the same output name.

0 commit comments

Comments
 (0)