Skip to content

Commit

Permalink
Also publish nightly binaries with Git commit ID
Browse files Browse the repository at this point in the history
This makes it possible for users to pin to specific commits for their nightly builds
  • Loading branch information
rm3l committed Jun 14, 2024
1 parent 6d83e40 commit 6c6517d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/nightly-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,36 @@ jobs:
with:
go-version-file: 'go.mod'

- name: Get commit ID
run: |
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 }}
run: |
version="$(git describe --no-match --always --abbrev=9 --dirty --broken 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)-nightly"
binName="odo-$GOOS-$GOARCH"
version="${{ env.SHORT_SHA }}-nightly"
binNameNoExt="odo-$GOOS-$GOARCH"
binName="${binNameNoExt}"
binNameWithSha="${binNameNoExt}=${{ env.SHORT_SHA }}"
if [ $GOOS == "windows" ]; then
binName="${binName}.exe"
binNameWithSha="${binNameWithSha}.exe"
fi
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
run: |
if [ $GOOS == "windows" ]; then
zip -9 -y -r -q "odo-${GOOS}-${GOARCH}.zip" "odo-${GOOS}-${GOARCH}.exe"
zip -9 -y -r -q "odo-${GOOS}-${GOARCH}.zip" "odo-${GOOS}-${GOARCH}.exe" "odo-${GOOS}-${GOARCH}-${{ env.SHORT_SHA }}.exe"
else
tar -czvf "odo-${GOOS}-${GOARCH}.tar.gz" "odo-${GOOS}-${GOARCH}"
tar -czvf "odo-${GOOS}-${GOARCH}.tar.gz" "odo-${GOOS}-${GOARCH}" "odo-${GOOS}-${GOARCH}-${{ env.SHORT_SHA }}"
fi
- name: Generate SHA-256 checksums
Expand Down

0 comments on commit 6c6517d

Please sign in to comment.