From a7b45bf9a692d217bc5248708ba5b340dab88ab2 Mon Sep 17 00:00:00 2001 From: Brice Redmond Date: Thu, 7 Nov 2024 15:46:45 -0800 Subject: [PATCH] [patch] fix release.sh 2 problems: - the s3 publishes should not have had acl (i got this from what was there before) - the npm publish needs a valid token --- .github/workflows/build-push.yml | 72 +++++++++++------------- .github/workflows/deploy-release.yml | 11 +++- deployment/{release.sh => release-s3.sh} | 6 +- 3 files changed, 46 insertions(+), 43 deletions(-) rename deployment/{release.sh => release-s3.sh} (91%) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index be4cf724..b2f3b99a 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -25,6 +25,40 @@ jobs: java-version: ${{ env.JAVA_VERSION }} distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Install branch-github-actions + uses: actions/checkout@v4 + with: + repository: BranchMetrics/branch-github-actions + ref: master + path: .branch-github-actions + token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }} + + - name: Add INPUT_SHA env var + run: | + export INPUT_SHA=$(git rev-parse ${{ github.ref }}) + echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV + + - name: Get next release version + uses: actions/github-script@v7 + id: next-version + with: + result-encoding: string + script: | + const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version'); + const nextVersion = await getNextVersion({ + core, + github, + context, + sha: process.env.INPUT_SHA, + }); + return nextVersion; + env: + INPUT_SHA: ${{ env.INPUT_SHA }} + + - name: Write version to files + run: | + ./deployment/write-versions.sh ${{ steps.next-version.outputs.result }} + - name: Install dependencies run: npm run ci @@ -67,44 +101,6 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - name: Install branch-github-actions - if: ${{ github.ref == 'refs/heads/master' }} - uses: actions/checkout@v4 - with: - repository: BranchMetrics/branch-github-actions - ref: master - path: .branch-github-actions - token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }} - - - name: Add INPUT_SHA env var - if: ${{ github.ref == 'refs/heads/master' }} - run: | - export INPUT_SHA=$(git rev-parse ${{ github.ref }}) - echo "INPUT_SHA=`echo $INPUT_SHA`" >> $GITHUB_ENV - - - name: Get next release version - if: ${{ github.ref == 'refs/heads/master' }} - uses: actions/github-script@v7 - id: next-version - with: - result-encoding: string - script: | - const getNextVersion = require('./.branch-github-actions/custom-scripts/next-version'); - const nextVersion = await getNextVersion({ - core, - github, - context, - sha: process.env.INPUT_SHA, - }); - return nextVersion; - env: - INPUT_SHA: ${{ env.INPUT_SHA }} - - - name: Write version to files - if: ${{ github.ref == 'refs/heads/master' }} - run: | - ./deployment/write-versions.sh ${{ steps.next-version.outputs.result }} - - name: Deploy updated builds to staging if: ${{ github.ref == 'refs/heads/master' }} id: build diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 928aeb79..eed558d5 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -68,9 +68,16 @@ jobs: - name: Configure NPM run: npm ci - - name: Release to npm, s3, prod + - run: make release + + - name: Publish to s3 run: | - ./deployment/release.sh ${{ steps.next-version.outputs.result }} + ./deployment/release-s3.sh ${{ steps.next-version.outputs.result }} + + - name: Publish to npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISHER_TOKEN }} + run: npm publish - name: Create Github Release uses: actions/github-script@v7 diff --git a/deployment/release.sh b/deployment/release-s3.sh similarity index 91% rename from deployment/release.sh rename to deployment/release-s3.sh index 0922cb58..68de6b43 100755 --- a/deployment/release.sh +++ b/deployment/release-s3.sh @@ -12,15 +12,15 @@ make release ./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js" aws s3 cp example.html s3://branch-builds/example.html +aws s3 cp example.html s3://branch-cdn/example.html -aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --acl public-read -aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --acl public-read +aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-$VERSION.min.js --cache-control "max-age=300" +aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-latest.min.js --cache-control "max-age=300" echo -en "Invalidating cloudfront distribution...\n" aws configure set preview.cloudfront true aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-latest.min.js -npm publish echo "Post-release sanity checks." read -p "Can you visit https://cdn.branch.io/branch-$VERSION.min.js ?" -n 1 -r