Skip to content

Commit

Permalink
Add action to update vscode extension with latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
emmawillis committed May 31, 2024
1 parent ded31f3 commit ade1f40
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 26 deletions.
58 changes: 58 additions & 0 deletions .github/actions/update-vscode-extension/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Update VSCode Extension

description: 'Update the CLI version in vscode-extension'

inputs:
latest_tag:
required: true
description: 'The latest tag from the workflow that uses this action'
access_token:
required: true
description: 'The access token to use for authentication'

runs:
using: 'composite'
steps:
- name: Check out code
uses: actions/checkout@v3
with:
repository: DevCycleHQ/vscode-extension
path: vscode-extension
token: ${{ inputs.access_token }}
fetch-depth: 0

- name: Set Git author
shell: bash
working-directory: vscode-extension
run: |
git config --global user.email "github-tracker-bot@taplytics.com"
git config --global user.name "DevCycle Automation"
- name: Set branch name
shell: bash
working-directory: vscode-extension
run: echo "BRANCH_NAME=update-cli-version-to-${{ inputs.latest_tag }}" >> $GITHUB_ENV

- name: Update CLI version in vscode extension
shell: bash
working-directory: vscode-extension
run: |
# Remove 'v' prefix from latest_tag
CLI_VERSION="${{ inputs.latest_tag }}"
CLI_VERSION="${CLI_VERSION#v}"
git checkout -b "$BRANCH_NAME"
sed -i "s/export const CLI_VERSION = .*/export const CLI_VERSION = '${{ CLI_VERSION }}' \/\/ auto updated by dvc cli release workflow/" src/constants.ts
git add src/constants.ts
git commit -m "Update CLI version to ${{ inputs.latest_tag }}"
- name: Push code to extension repo
shell: bash
working-directory: vscode-extension
run: git push --set-upstream origin "$BRANCH_NAME"

- name: Create PR
shell: bash
working-directory: vscode-extension
env:
GH_TOKEN: ${{ inputs.access_token }}
run: gh pr create --repo DevCycleHQ/vscode-extension --base main --head "$BRANCH_NAME" --title "Update CLI version to $LATEST_TAG" --body "This PR was automatically created by the DevCycle CLI release workflow."
59 changes: 33 additions & 26 deletions .github/workflows/cli-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,40 +60,47 @@ jobs:
- name: Build
run: yarn build

- name: Bump CLI version
run: npm version ${{ inputs.npm-version }} --force
# - name: Bump CLI version
# run: npm version ${{ inputs.npm-version }} --force

- name: Get latest tag
run: echo "LATEST_TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV

- name: Commit and push tag to main branch
run: |
git add .
git commit --amend -m "Release $LATEST_TAG"
git tag -f $LATEST_TAG
git push --atomic origin main $LATEST_TAG
# - name: Commit and push tag to main branch
# run: |
# git add .
# git commit --amend -m "Release $LATEST_TAG"
# git tag -f $LATEST_TAG
# git push --atomic origin main $LATEST_TAG

- name: Release
uses: ./.github/actions/release
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# cannot read $LATEST_TAG here so using ${{ env.LATEST_TAG }}
release-tag: ${{ env.LATEST_TAG }}
draft: ${{ inputs.draft-release }}
prerelease: ${{ inputs.prerelease }}
node-auth-token: ${{ secrets.CLI_NPMJS_TOKEN }}
# - name: Release
# uses: ./.github/actions/release
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# # cannot read $LATEST_TAG here so using ${{ env.LATEST_TAG }}
# release-tag: ${{ env.LATEST_TAG }}
# draft: ${{ inputs.draft-release }}
# prerelease: ${{ inputs.prerelease }}
# node-auth-token: ${{ secrets.CLI_NPMJS_TOKEN }}

# - name: Update Doc
# uses: ./.github/actions/update-doc
# with:
# latest_tag: $LATEST_TAG
# access_token: ${{ secrets.AUTOMATION_USER_TOKEN }}

- name: Update Doc
uses: ./.github/actions/update-doc
- name: Update VSCode Extension
if: inputs.npm-version == 'minor' || inputs.npm-version == 'patch'
uses: ./.github/actions/update-vscode-extension
with:
latest_tag: $LATEST_TAG
access_token: ${{ secrets.AUTOMATION_USER_TOKEN }}

# Move this to release action yml once it works the first time
- name: Update Homebrew Formula
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.AUTOMATION_USER_TOKEN }}
repository: DevCycleHQ/homebrew-cli
event-type: start-deploy
# # Move this to release action yml once it works the first time
# - name: Update Homebrew Formula
# uses: peter-evans/repository-dispatch@v2
# with:
# token: ${{ secrets.AUTOMATION_USER_TOKEN }}
# repository: DevCycleHQ/homebrew-cli
# event-type: start-deploy

0 comments on commit ade1f40

Please sign in to comment.