From 4ae3ea08b375a793c5f15fa1d7393055e167b224 Mon Sep 17 00:00:00 2001 From: Chief Marlin <96321026+chiefMarlin@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:25:27 -0400 Subject: [PATCH] Update release.yml --- .github/workflows/release.yml | 76 ++++++++--------------------------- 1 file changed, 17 insertions(+), 59 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eaeb2ef..4aa4636 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,59 +22,7 @@ jobs: build_and_release: runs-on: ubuntu-latest steps: - - name: Checkout the repository - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 'stable' - - - name: Install dependencies - run: go mod download - - - name: Build binaries - run: | - mkdir -p ${{ env.BUILD_DIR }} - PLATFORMS=( - "darwin/arm64" - "darwin/amd64" - "linux/arm64" - "linux/amd64" - "windows/amd64" - "windows/arm64" - "freebsd/386" - "freebsd/amd64" - "freebsd/arm" - "freebsd/arm64" - "openbsd/386" - "openbsd/amd64" - "openbsd/arm" - "openbsd/arm64" - "dragonfly/amd64" - "netbsd/386" - "netbsd/amd64" - "netbsd/arm" - "netbsd/arm64" - ) - for PLATFORM in "${PLATFORMS[@]}"; do - GOOS=${PLATFORM%/*} - GOARCH=${PLATFORM#*/} - OUTPUT_NAME=${{ env.BINARY_PREFIX }}.$GOOS.$GOARCH - if [ "$GOOS" = "windows" ]; then - OUTPUT_NAME=$OUTPUT_NAME.exe - fi - echo "Building for $GOOS/$GOARCH..." - GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X 'main.Version=$(date +'%Y-%m-%d_%H:%M:%S')'" -o "${{ env.BUILD_DIR }}/$OUTPUT_NAME" ${{ env.SOURCE_DIR }} - done - - - name: Delete existing release - uses: dev-drprasad/delete-tag-and-release@v0.2.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.TAG }} - delete_release: true + # ... (previous steps remain the same) - name: Create Release id: create_release @@ -122,12 +70,22 @@ jobs: const stat = await fs.stat(filePath); if (stat.isFile()) { console.log(`Uploading ${file}...`); - await github.rest.repos.uploadReleaseAsset({ - url: uploadUrl, - headers: { 'content-type': 'application/octet-stream' }, - name: file, - data: await fs.readFile(filePath) - }); + const fileContent = await fs.readFile(filePath); + try { + const response = await github.rest.repos.uploadReleaseAsset({ + url: uploadUrl, + headers: { + 'content-type': 'application/octet-stream', + 'content-length': fileContent.length, + }, + name: file, + data: fileContent, + }); + console.log(`Successfully uploaded ${file}`); + } catch (error) { + console.error(`Failed to upload ${file}: ${error.message}`); + throw error; + } } }