diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3127868f73..135ccf7432 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - alpha schedule: - cron: '*/5 * * * *' @@ -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" diff --git a/scripts/bump-sha.sh b/scripts/bump-sha.sh index 652cebef7a..82aebb46f6 100755 --- a/scripts/bump-sha.sh +++ b/scripts/bump-sha.sh @@ -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" diff --git a/scripts/check-update.sh b/scripts/check-update.sh index 2d7b295992..1fa926efae 100644 --- a/scripts/check-update.sh +++ b/scripts/check-update.sh @@ -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 @@ -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 \ No newline at end of file diff --git a/scripts/publish.sh b/scripts/publish.sh index ee62772a7b..531b4b247b 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -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