Skip to content

Commit

Permalink
feat(alpha): via a new extension
Browse files Browse the repository at this point in the history
- Fixes #47
- Fixes #93

This PR is made against "alpha" and merging this should release a "new"
alpha extension.
  • Loading branch information
Divyendu Singh committed Apr 21, 2020
1 parent 04ab7da commit 80c2a38
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- alpha
schedule:
- cron: '*/5 * * * *'

Expand All @@ -16,10 +17,23 @@ jobs:
publish:
name: Publish
runs-on: ubuntu-latest
if: endsWith(github.ref, '/master')
if: endsWith(github.ref, '/master') || endsWith(github.ref, '/alpha')
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: npm install
- name: Publish Extension as Patch
run: yarn vsce:check
run: yarn vsce:check "latest"

publish-alpha:
name: Publish Alpha
runs-on: ubuntu-latest
if: endsWith(github.ref, '/master') || endsWith(github.ref, '/alpha')
steps:
- uses: actions/checkout@v2
with:
ref: alpha
- name: Install Dependencies
run: npm install
- name: Publish Extension as Patch
run: yarn vsce:check "alpha"
14 changes: 12 additions & 2 deletions scripts/bump-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

set -eu

CHANNEL=$1
echo "CHANNEL: $CHANNEL"

OLD_SHA=$(jq ".prisma.version" ./package.json)

SHA=$(npx -q -p @prisma/cli@latest prisma2 --version | grep "Query Engine" | awk '{print $5}')
jq ".prisma.version = \"$SHA\"" ./package.json > ./package.json.bk
SHA=$(npx -q -p @prisma/cli@"$CHANNEL" prisma2 --version | grep "Query Engine" | awk '{print $5}')

# If the channel is alpha, we need to change the name, displayName to the alpha extension
if [ "$CHANNEL" = "alpha" ]; then
jq ".prisma.version = \"$SHA\" | .name = \"prisma-alpha\" | .displayName = \"Prisma Alpha\"" ./package.json > ./package.json.bk
else
jq ".prisma.version = \"$SHA\"" ./package.json > ./package.json.bk
fi

mv ./package.json.bk ./package.json

echo "Bumped prisma.version in package.json from $OLD_SHA to $SHA"
26 changes: 21 additions & 5 deletions scripts/check-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

set -eu

# For local development, in production, the environment will be set though GH actions and GH secrets
if [ -f ".envrc" ]; then
echo "Loading .envrc"
# shellcheck disable=SC1091
. .envrc
else
echo "No .envrc"
fi

CHANNEL=$1
echo "CHANNEL: $CHANNEL"

CURRENT_VERSION=$(cat scripts/prisma_version)
echo "CURRENT_VERSION: $CURRENT_VERSION"

NPM_VERSION=$(sh scripts/prisma-version.sh "latest")
NPM_VERSION=$(sh scripts/prisma-version.sh "$CHANNEL")
echo "NPM_VERSION: $NPM_VERSION"

# Setup the repo with GH_TOKEN to avoid running jobs when CI commits
Expand All @@ -20,10 +32,14 @@ fi
if [ "$CURRENT_VERSION" != "$NPM_VERSION" ]; then
echo "UPDATING to $NPM_VERSION"
echo "$NPM_VERSION" > scripts/prisma_version
sh ./scripts/bump-sha.sh
git add -A .
git commit -m "bump prisma_version to $NPM_VERSION"
yarn run vsce:publish
sh ./scripts/bump-sha.sh "$CHANNEL"
if [ "$PRODUCTION" = "1" ]; then
git add -A .
git commit -m "bump prisma_version to $NPM_VERSION"
else
echo "Not committing because production is not set"
fi
yarn run vsce:publish "$CHANNEL"
else
echo "CURRENT_VERSION ($CURRENT_VERSION) and NPM_VERSION ($NPM_VERSION) are same"
fi
12 changes: 9 additions & 3 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ echo "AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN: $AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN"
echo "PRODUCTION: $PRODUCTION"
echo "============================"

PRISMA_VERSION=$(cat scripts/prisma_version)
echo "PRISMA_VERSION: $PRISMA_VERSION"

CHANNEL=$1
echo "CHANNEL: $CHANNEL"

# Try to publish if $AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN (Personal Access Token - https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token) exists
if [ -z "$AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN" ]; then
echo "\$AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN is empty. Please set the value of $AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN"
elif [ -n "$AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN" ]; then
if [ "$PRODUCTION" = "1" ]; then
echo "Publishing patch release"
./node_modules/.bin/vsce publish patch --pat "$AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN"
echo "Publishing $CHANNEL release"
./node_modules/.bin/vsce publish "$PRISMA_VERSION" --pat "$AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN"
else
echo "Printing the command because PRODUCTION is not set"
echo "sh ./scripts/bump-sha.sh" # The actual execution of this command is in check-update.sh becuase git working tree must be clean before calling `vsce publish`
echo "./node_modules/.bin/vsce publish patch --pat $AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN"
echo "./node_modules/.bin/vsce publish \"$PRISMA_VERSION\" --pat $AZURE_DEVOPS_PERSONAL_ACCESS_TOKEN"
fi
fi

Expand Down

0 comments on commit 80c2a38

Please sign in to comment.