Skip to content

Commit

Permalink
Do not override binary for commit ID if there is already one uploaded
Browse files Browse the repository at this point in the history
Otherwise, this will regenerate a different checksum

Fixes #7256
  • Loading branch information
rm3l committed Jul 3, 2024
1 parent 082e307 commit 230d437
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/nightly-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ jobs:
sha=$(git describe --no-match --always --abbrev=9 --dirty --broken 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
echo "SHORT_SHA=${sha}" >> "$GITHUB_ENV"
- name: Cross-compile
env:
PROJECT: "github.com/redhat-developer/odo"
RELEASE_SEGMENT_WRITE_KEY: ${{ secrets.RELEASE_SEGMENT_WRITE_KEY }}
- name: Determine bin info
run: |
version="${{ env.SHORT_SHA }}-nightly"
binNameNoExt="odo-$GOOS-$GOARCH"
Expand All @@ -98,13 +95,37 @@ jobs:
binName="${binName}.exe"
binNameWithSha="${binNameWithSha}.exe"
fi
echo "BIN_NAME=${binName}" >> "$GITHUB_ENV"
echo "BIN_NAME_WITH_SHA=${binNameWithSha}" >> "$GITHUB_ENV"
- name: Determine if binary exists for commit ID
id: check_bin
run: |
baseUrl="https://s3.${IBM_CLOUD_REGION}.cloud-object-storage.appdomain.cloud/${IBM_CLOUD_OBJECT_STORAGE_BUCKET}"
binNameWithSha="${{ env.BIN_NAME_WITH_SHA }}"
binExists="false"
if curl -sfILo /dev/null "${baseUrl}/${binNameWithSha}"; then
binExists="true"
fi
echo "binExists=${binExists}" >> "$GITHUB_OUTPUT"
- name: Cross-compile
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
env:
PROJECT: "github.com/redhat-developer/odo"
RELEASE_SEGMENT_WRITE_KEY: ${{ secrets.RELEASE_SEGMENT_WRITE_KEY }}
run: |
version="${{ env.SHORT_SHA }}-nightly"
binName="${{ env.BIN_NAME }}"
binNameWithSha="${{ env.BIN_NAME_WITH_SHA }}"
go build -o "$binName" \
-mod=vendor \
-ldflags="-s -w -X ${PROJECT}/pkg/segment.writeKey=${RELEASE_SEGMENT_WRITE_KEY} -X ${PROJECT}/pkg/version.GITCOMMIT=${version}" \
./cmd/odo/
cp -vr "$binName" "${binNameWithSha}"
- name: Generate archive
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
run: |
if [ $GOOS == "windows" ]; then
zip -9 -y -r -q "odo-${GOOS}-${GOARCH}.zip" "odo-${GOOS}-${GOARCH}.exe"
Expand All @@ -115,24 +136,28 @@ jobs:
fi
- name: Generate SHA-256 checksums
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
run: |
for f in `find . -type f -name 'odo-${{ matrix.os }}-${{ matrix.arch }}*'`; do
bin=$(realpath "$f")
sha256sum -b "${bin}" | awk '{print $1}' > "${bin}".sha256
done
- name: Install IBM Cloud CLI
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f cloud-object-storage
- name: Authenticate with IBM Cloud CLI
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
run: |
ibmcloud login --apikey "${IBM_CLOUD_API_KEY}" -r "${IBM_CLOUD_REGION}" -g "${IBM_CLOUD_RESOURCE_GROUP}" --quiet
- name: Set CRN
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
run: |
CRN=$(ibmcloud resource service-instance "${IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE}" --output json | jq -r '.[0].guid | values')
if [[ -z "$CRN" ]]; then
Expand All @@ -142,6 +167,7 @@ jobs:
ibmcloud cos config crn --crn "${CRN}"
- name: Upload binaries
if: ${{ steps.check_bin.outputs.binExists != 'true' }}
run: |
baseUrl="https://s3.${IBM_CLOUD_REGION}.cloud-object-storage.appdomain.cloud/${IBM_CLOUD_OBJECT_STORAGE_BUCKET}"
for f in `find . -type f -name 'odo-${{ matrix.os }}-${{ matrix.arch }}*'`; do
Expand Down

0 comments on commit 230d437

Please sign in to comment.