Skip to content

Commit

Permalink
feat(script): auto add binary version to s3 file (#142)
Browse files Browse the repository at this point in the history
* add version txt

* fixed task name

* fixed url

* fixed url

* opti title

* finish test

* fixed platform

* fixed pre-commit
  • Loading branch information
jhd2best authored and leeren committed Oct 15, 2024
1 parent 1b08594 commit ea78a32
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
echo "Version extracted: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_META=$VERSION_META" >> $GITHUB_ENV
- name: Build the story binary
run: |
Expand All @@ -87,6 +88,7 @@ jobs:
COMMIT_HASH=$(git rev-parse --short HEAD)
FOLDER_NAME="story-${{ matrix.platform }}-${VERSION}-${COMMIT_HASH}"
ARCHIVE_NAME="${FOLDER_NAME}.tar.gz"
PUBLIC_DOWNLOAD_URL="https://$S3_BUCKET.s3.us-west-1.amazonaws.com/$BIN_NAME-public/$ARCHIVE_NAME"
BIN_NAME_WITH_PATH=./client/$BIN_NAME
if [ "$GOOS" = "windows" ]; then
Expand Down Expand Up @@ -115,8 +117,31 @@ jobs:
aws s3 cp s3://$S3_BUCKET/$BIN_NAME/manifest.txt manifest.txt --quiet || touch manifest.txt
echo "$TIMESTAMP" >> manifest.txt
aws s3 cp manifest.txt s3://$S3_BUCKET/$BIN_NAME/manifest.txt --quiet
# Update version file
aws s3 cp s3://$S3_BUCKET/$BIN_NAME-public/version.txt version.txt --quiet || printf "File Name\t\t\tVerison\t\t\t\tCommit Hash\t\tTimestamp\n" > version.txt
if [ "${VERSION_META}" != "stable" ]; then
printf "$VERSION-$COMMIT_HASH\t\t$VERSION\t\t\t$COMMIT_HASH\t\t\t$TIMESTAMP\n" >> version.txt
else
printf "$VERSION-$COMMIT_HASH\t\t\t$VERSION\t\t\t\t$COMMIT_HASH\t\t\t$TIMESTAMP\n" >> version.txt
fi
aws s3 cp version.txt s3://$S3_BUCKET/$BIN_NAME-public/version.txt --quiet
fi
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
echo "PUBLIC_DOWNLOAD_URL=$PUBLIC_DOWNLOAD_URL" >> $GITHUB_ENV
- name: Add binary version back to PR
if: matrix.platform == 'linux-amd64'
uses: mshick/add-pr-comment@v2
with:
message: |
### Binary uploaded successfully 🎉
📦 **Version Name:** ${{ env.VERSION }}-${{ env.COMMIT_HASH }}
📦 **Download Source:** [AWS S3](${{ env.PUBLIC_DOWNLOAD_URL }})
cleanup:
runs-on: ubuntu-latest
needs: build_and_push
Expand Down

0 comments on commit ea78a32

Please sign in to comment.