diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7451713 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,115 @@ +name: Release + +on: + push: + tags: + - 'v*' # Triggers on version tags like v1.0.0, v1.2.3, etc. + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + + - name: Extract version from tag + id: extract_version + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/v} + echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT + echo "Tag version: $TAG_VERSION" + + - name: Extract version from package.json + id: package_version + run: | + PACKAGE_VERSION=$(node -p "require('./package.json').version") + echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT + echo "Package version: $PACKAGE_VERSION" + + - name: Compare versions + run: | + if [ "${{ steps.extract_version.outputs.tag_version }}" != "${{ steps.package_version.outputs.package_version }}" ]; then + echo "❌ Version mismatch!" + echo "Tag version: ${{ steps.extract_version.outputs.tag_version }}" + echo "Package.json version: ${{ steps.package_version.outputs.package_version }}" + echo "Please ensure the tag version matches the version in package.json" + exit 1 + fi + echo "✅ Version check passed: ${{ steps.extract_version.outputs.tag_version }}" + + - name: Install dependencies + run: npm ci + + - name: Run linting + run: npm run lint + + - name: Run type checking + run: npm run check-types + + - name: Compile extension + run: npm run compile + + - name: Build production package + run: npm run package + + - name: Compile tests + run: npm run compile-tests + + - name: Run tests + uses: coactions/setup-xvfb@v1 + with: + run: npm test + options: -screen 0 1024x768x24 + continue-on-error: false # Fail the release if tests fail + + - name: Create VSIX package + run: npx vsce package + + - name: Get VSIX filename + id: vsix_filename + run: | + VSIX_FILE=$(ls *.vsix | head -n 1) + echo "vsix_file=$VSIX_FILE" >> $GITHUB_OUTPUT + echo "VSIX file: $VSIX_FILE" + + - name: Generate release notes + id: release_notes + run: | + # Extract the latest changes from CHANGELOG.md if it has been updated + # If not, create basic release notes + if grep -q "## \[.*\]" CHANGELOG.md; then + # Try to extract the latest version section from changelog + NOTES=$(sed -n '/## \[.*\]/,/## \[.*\]/p' CHANGELOG.md | head -n -1 | tail -n +2) + if [ -n "$NOTES" ]; then + echo "notes<> $GITHUB_OUTPUT + echo "$NOTES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + else + echo "notes=Release ${{ steps.extract_version.outputs.tag_version }}" >> $GITHUB_OUTPUT + fi + else + echo "notes=Release ${{ steps.extract_version.outputs.tag_version }}" >> $GITHUB_OUTPUT + fi + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Create release with notes and upload VSIX file + gh release create ${{ github.ref_name }} \ + --title "Release ${{ steps.extract_version.outputs.tag_version }}" \ + --notes "${{ steps.release_notes.outputs.notes }}" \ + ./${{ steps.vsix_filename.outputs.vsix_file }} + + - name: Release Summary + run: | + echo "🎉 Release ${{ steps.extract_version.outputs.tag_version }} created successfully!" + echo "📦 VSIX package: ${{ steps.vsix_filename.outputs.vsix_file }}" + echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5096b3c..a44b88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## [Unreleased] -- Initial release \ No newline at end of file +- Automated VSIX build and release workflow + +## [0.0.1] - Initial Release + +- Initial release +- Real-time token tracking with status bar display +- Automatic updates every 5 minutes +- Click to refresh functionality +- Smart estimation using character-based analysis +- Detailed view with comprehensive statistics \ No newline at end of file diff --git a/README.md b/README.md index a7e5a12..2a0b159 100644 --- a/README.md +++ b/README.md @@ -75,5 +75,27 @@ The project includes comprehensive GitHub Actions workflows: - **Build Pipeline**: Tests the extension on Ubuntu, Windows, and macOS with Node.js 18.x and 20.x - **CI Pipeline**: Includes VS Code extension testing and VSIX package creation +- **Release Pipeline**: Automated release creation when version tags are pushed - All builds must pass linting, type checking, compilation, and packaging steps +### Automated Releases + +The project supports automated VSIX builds and releases when version tags are pushed: + +1. Update the version in `package.json` +2. Commit your changes +3. Create and push a version tag: + ```bash + git tag v1.0.0 + git push origin v1.0.0 + ``` + +The release workflow will: +- Verify the tag version matches `package.json` version +- Run the full build pipeline (lint, type-check, compile, test) +- Create a VSIX package +- Create a GitHub release with auto-generated release notes +- Attach the VSIX file as a release asset + +**Note**: The workflow will fail if the tag version doesn't match the version in `package.json`. +