|
46 | 46 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
47 | 47 | GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
|
48 | 48 |
|
| 49 | + - name: Authenticate to Google Cloud |
| 50 | + uses: google-github-actions/auth@v2 |
| 51 | + with: |
| 52 | + credentials_json: ${{ secrets.GCP_SA_KEY }} |
| 53 | + |
49 | 54 | - name: Get Build Information
|
50 | 55 | id: build_info
|
51 | 56 | run: |
|
@@ -98,6 +103,47 @@ jobs:
|
98 | 103 | docker stop $(docker ps -q --filter ancestor=${image_tag})
|
99 | 104 | done
|
100 | 105 |
|
| 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 | +
|
101 | 147 | outputs:
|
102 | 148 | # matrix jobs outputs override each other, but we use the same sha
|
103 | 149 | # for all images, so we can use the same output name.
|
|
0 commit comments