Skip to content

Commit

Permalink
Require manual updates to the package.json
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Egan <[email protected]>
  • Loading branch information
charlieegan3 committed Apr 4, 2024
1 parent 456c9ba commit 8380171
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
name: Publish Release

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g. 0.0.0)'
required: true
push:
tags:
- '*'

jobs:
publish:
permissions:
# allow the workflow to update the repository with the new tag
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check that package.json is up-to-date
run: |
# this version has no v prefix, e.g. 1.0.0
VERSION_FROM_PACKAGE_JSON=$(jq -r '.version' package.json)
# the GITHUB_REF_NAME is the tag name, e.g. v1.0.0
VERSION_FROM_GITHUB_REF_NAME=${GITHUB_REF_NAME:1} # remove the v prefix
if [ "$VERSION_FROM_PACKAGE_JSON" = "$VERSION_FROM_GITHUB_REF_NAME" ]; then
echo "The versions match, proceeding to publish."
else
echo "Please update the version in package.json to match the tag."
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -29,9 +38,4 @@ jobs:
run: npm install -g vsce

- name: Publish
run: vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} ${{ github.event.inputs.tag }}

- name: Push tag
run: |
git push origin master
git push origin "v${{ github.event.inputs.tag }}"
run: vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} $GITHUB_REF_NAME

0 comments on commit 8380171

Please sign in to comment.