Skip to content

Commit

Permalink
update to make staging and prod sync
Browse files Browse the repository at this point in the history
  • Loading branch information
bredmond5 committed Nov 6, 2024
1 parent 39fbda1 commit 3453cb9
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 3,501 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ jobs:
- name: upload codecov
uses: codecov/codecov-action@v4

- name: check whether updated build files are checked in
run: |
make
git diff --exit-code || (echo "Please run \"make\" and commit changes to dist/build.js and dist/build.min.js" && exit 1)
- name: Check whether we will be able to make the release
run: make release

Expand All @@ -72,6 +67,19 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Get the current release version
if: ${{ github.ref == 'refs/heads/master' }}
id: current-version
run: |
current_version=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "Current version is $current_version"
echo "result=$current_version" >> $GITHUB_OUTPUT
- name: Write version to files
if: ${{ github.ref == 'refs/heads/master' }}
run: |
./deployment/write-versions.sh ${{ steps.current-version.outputs.result }}
- name: Deploy updated builds to staging
if: ${{ github.ref == 'refs/heads/master' }}
id: build
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,21 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}

- name: Bump package.json version
- name: Write version to files
run: |
sed -i -e "s/\"version\":.*$/\"version\": \"$GE_NEXT_VERSION\",/" package.json
env:
GE_NEXT_VERSION: ${{ steps.next-version.outputs.result }}
./deployment/write-versions.sh ${{ steps.next-version.outputs.result }}
- name: Configure NPM
run: npm ci

- name: Release to npm, s3
- name: Release to npm, s3, prod
run: |
./deployment/release.sh ${{ steps.next-version.outputs.result }}
# We deploy to stage to send the updated release numbers. The code should not be any different
- name: Release to stage
run: |
./release.sh v${{ steps.next-version.outputs.result }}
./deployment/deploy-qa.sh ${{ steps.next-version.outputs.result }}
- name: Create Github Release
uses: actions/github-script@v7
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ test-results.json
.direnv/
dev.config
dev.html
example.html
example.html
dist/
26 changes: 2 additions & 24 deletions release.sh → deployment/release.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
#!/bin/bash

[ $# -eq 0 ] && { echo "Usage: $0 v1.0.0"; exit 1; }
[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; }

VERSION_NO_V=$(echo $1 | tr -d "\nv")
VERSION_NO_V=$1
VERSION="v"$VERSION_NO_V
DATE=$(date "+%Y-%m-%d")

echo "Releasing Branch Web SDK"

# check whether on master branch
branch_name="$(git symbolic-ref HEAD 2>/dev/null)"
branch_name=${branch_name##refs/heads/}
if [ $branch_name != "master" ]; then
echo "ERROR: not on master branch: "$branch_name
exit 1
fi

# check whether the branch is clean
check_git_branch() {
if [[ $(git status --porcelain 2> /dev/null | tail -n1) != "" ]]
then
echo 'ERROR: branch dirty'
exit 1
fi
}

check_git_branch

sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" src/0_config.js
sed -i -e "s/version = '.*';$/version = '$VERSION_NO_V';/" test/web-config.js

make release

./deployment/build-example-html.sh "key_live_hcnegAumkH7Kv18M8AOHhfgiohpXq5tB" "https://api2.branch.io" "https://cdn.branch.io/branch-latest.min.js"
Expand Down
7 changes: 7 additions & 0 deletions deployment/write-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

[ $# -eq 0 ] && { echo "Usage: $0 1.0.0"; exit 1; }

sed -i -e "s/version = '.*';$/version = '$1';/" package.json
sed -i -e "s/version = '.*';$/version = '$1';/" src/0_config.js
sed -i -e "s/version = '.*';$/version = '$1';/" test/web-config.js
Loading

0 comments on commit 3453cb9

Please sign in to comment.