Skip to content

chore: bump version to 0.3.0 in package.json #39

chore: bump version to 0.3.0 in package.json

chore: bump version to 0.3.0 in package.json #39

Workflow file for this run

name: Release Extension
on:
push:
branches:
- main
paths:
- 'package.json' # Trigger only when package.json is modified
jobs:
release:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
# Step 1: Checkout the Repository
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history to access tags
# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # Use your project's Node.js version
# Step 3: Install Dependencies
- name: Install Dependencies
run: npm install
# Step 4: Build the Extension
- name: Build Extension
run: npm run build
# Step 5: Extract Current Version from package.json
- name: Get Current Version
id: current_version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
# Step 6: Get Previous Tag Version
- name: Get Previous Tag
id: previous_tag
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ || echo "0.0.0")
echo "PREVIOUS_VERSION=$PREVIOUS_TAG" >> $GITHUB_ENV
# Step 7: Validate Version Increment
- name: Validate Version Increment
id: validate_version
run: |
npm install semver
node -e "
const semver = require('semver');
const currentVersion = process.env.CURRENT_VERSION;
const previousVersion = process.env.PREVIOUS_VERSION;
if (!semver.gt(currentVersion, previousVersion)) {
console.error('Error: Current version (' + currentVersion + ') is not greater than previous version (' + previousVersion + ').');
process.exit(1);
}
console.log('Version increment validated.');
"
env:
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
PREVIOUS_VERSION: ${{ env.PREVIOUS_VERSION }}
# Step 8: Install Ruby with Bundler Caching
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0' # Specify the Ruby version you need
bundler-cache: true # Enables automatic bundler caching
# Step 9: Install github-changelog-generator and faraday-retry
- name: Install Gems
run: |
gem install github_changelog_generator
gem install faraday-retry
# Step 10: Generate Changelog
- name: Generate Changelog
run: |
github_changelog_generator \
--user daniel-butler-irl \
--project VS_Code_Catalog_Json_Editor \
--output CHANGELOG.md \
--future-release "$CURRENT_VERSION" \
--since-tag "$PREVIOUS_VERSION" \
--token "$GITHUB_TOKEN"
env:
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
# Step 11: Commit and Push CHANGELOG.md
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: update CHANGELOG for version ${{ env.CURRENT_VERSION }}"
file_pattern: CHANGELOG.md
branch: main
# Step 12: Tag the New Version
- name: Create Git Tag
run: |
git tag $CURRENT_VERSION
git push origin $CURRENT_VERSION
env:
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
# Step 13: Package the Extension
- name: Package Extension
run: npx vsce package
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
# Step 14: Create GitHub Release
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.CURRENT_VERSION }}
name: Release v${{ env.CURRENT_VERSION }}
body_path: ./CHANGELOG.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
# Step 15: Upload .vsix to Release
- name: Upload .vsix to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ibm-catalog-json-editor-${{ env.CURRENT_VERSION }}.vsix
asset_name: ibm-catalog-json-editor-${{ env.CURRENT_VERSION }}.vsix
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
# Step 16: Publish to VS Code Marketplace
- name: Publish to VS Code Marketplace
run: npx vsce publish --pat ${{ secrets.VSCE_PAT }}
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}