From cc2851162bb8413256718f2753e57d223a11bc60 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 8 Aug 2024 10:09:04 +0200 Subject: [PATCH] Fix release job working directory Simplify the working directory management of the release job. Signed-off-by: Sascha Grunert (cherry picked from commit 42f500e18020d50bbf270373da83d1e068b260ec) --- .github/workflows/release.yml | 33 ++++++++------------------------- hack/release-notes.sh | 2 +- hack/release.sh | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d61a47c988..a3ee491193 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,43 +8,26 @@ jobs: name: release runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: false - - - name: Set env - shell: bash - run: | - echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV - echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - - uses: actions/cache@v4 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: go-release-${{ hashFiles('**/go.sum') }} - restore-keys: go-release- - uses: actions/checkout@v4 with: fetch-depth: 0 - path: src/github.com/kubernetes-sigs/cri-tools - - run: | - make release-notes release + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + - run: make release-notes release env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - working-directory: src/github.com/kubernetes-sigs/cri-tools - uses: ncipollo/release-action@v1 with: allowUpdates: true - artifacts: src/github.com/kubernetes-sigs/cri-tools/_output/releases/* - bodyFile: src/github.com/kubernetes-sigs/cri-tools/release-notes.md + artifacts: _output/releases/* + bodyFile: release-notes.md token: ${{ secrets.GH_TOKEN }} - uses: actions/upload-artifact@v4 with: name: release-notes - path: src/github.com/kubernetes-sigs/cri-tools/release-notes.md + path: release-notes.md - uses: actions/upload-artifact@v4 with: name: build-artifacts - path: src/github.com/kubernetes-sigs/cri-tools/_output + path: _output diff --git a/hack/release-notes.sh b/hack/release-notes.sh index 68ecedcf7d..42fad9813a 100755 --- a/hack/release-notes.sh +++ b/hack/release-notes.sh @@ -18,7 +18,7 @@ set -euo pipefail BUILD_DIR=build BINARY=$BUILD_DIR/release-notes -VERSION=v0.16.8 +VERSION=v0.17.2 mkdir -p $BUILD_DIR curl -sSfL --retry 5 --retry-delay 10 -o $BINARY \ diff --git a/hack/release.sh b/hack/release.sh index e5d00f3e32..ae3cd906b8 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -47,9 +47,9 @@ CRI_TEST_PLATFORMS=( # Create releases output directory. PROJECT="sigs.k8s.io/cri-tools" -CRI_TOOLS_ROOT="$GOPATH/src/$PROJECT" -OUTPUTDIR=$CRI_TOOLS_ROOT/_output/releases -mkdir -p "$OUTPUTDIR" +OUTPUT_DIR=_output +RELEASES_DIR=$OUTPUT_DIR/releases +mkdir -p "$RELEASES_DIR" GO_LDFLAGS="-X ${PROJECT}/pkg/version.Version=${VERSION}" @@ -63,14 +63,14 @@ for platform in "${CRI_CTL_PLATFORMS[@]}"; do CRICTL_BIN="crictl.exe" fi - output_bin=${CRI_TOOLS_ROOT}/_output/bin/$arch-$os/${CRICTL_BIN} + output_bin=$OUTPUT_DIR/bin/$arch-$os/${CRICTL_BIN} GOARCH="$arch" GOOS="$os" CGO_ENABLED=0 go build \ -o ${output_bin} \ -ldflags "${GO_LDFLAGS}" \ ${PROJECT}/cmd/crictl file ${output_bin} - tar zcf "$OUTPUTDIR/crictl-$VERSION-$os-$arch.tar.gz" \ - -C ${CRI_TOOLS_ROOT}/_output/bin/$arch-$os \ + tar zcf "$RELEASES_DIR/crictl-$VERSION-$os-$arch.tar.gz" \ + -C $OUTPUT_DIR/bin/$arch-$os \ ${CRICTL_BIN} done @@ -84,14 +84,14 @@ for platform in "${CRI_TEST_PLATFORMS[@]}"; do CRITEST_BIN="critest.exe" fi - output_bin=${CRI_TOOLS_ROOT}/_output/bin/$arch-$os/${CRITEST_BIN} + output_bin=$OUTPUT_DIR/bin/$arch-$os/${CRITEST_BIN} GOARCH="$arch" GOOS="$os" CGO_ENABLED=0 go test -c \ -o ${output_bin} \ -ldflags "${GO_LDFLAGS}" \ ${PROJECT}/cmd/critest file ${output_bin} - tar zcf "$OUTPUTDIR/critest-$VERSION-$os-$arch.tar.gz" \ - -C ${CRI_TOOLS_ROOT}/_output/bin/$arch-$os \ + tar zcf "$RELEASES_DIR/critest-$VERSION-$os-$arch.tar.gz" \ + -C $OUTPUT_DIR/bin/$arch-$os \ ${CRITEST_BIN} done @@ -101,14 +101,14 @@ echo "| ---- | ------ | ------" | tee -a release-notes.md # Show sha256/512 for release files if [[ "${OSTYPE}" == "darwin"* ]]; then - for file in "$OUTPUTDIR"/*.tar.gz; do + for file in "$RELEASES_DIR"/*.tar.gz; do SHA256=$(shasum -a 256 "$file" | sed -e "s,$file,," | awk '{print $1}' | tee "$file.sha256") SHA512=$(shasum -a 512 "$file" | sed -e "s,$file,," | awk '{print $1}' | tee "$file.sha512") BASE=$(basename "$file") echo "| $BASE | $SHA256 | $SHA512 |" | tee -a release-notes.md done else - for file in "$OUTPUTDIR"/*.tar.gz; do + for file in "$RELEASES_DIR"/*.tar.gz; do SHA256=$(sha256sum -b "$file" | sed -e "s,$file,," | awk '{print $1}' | tee "$file.sha256") SHA512=$(sha512sum -b "$file" | sed -e "s,$file,," | awk '{print $1}' | tee "$file.sha512") BASE=$(basename "$file")