Skip to content

modified abuncha stuff in package.json so its properly handling stuff… #17

modified abuncha stuff in package.json so its properly handling stuff…

modified abuncha stuff in package.json so its properly handling stuff… #17

name: Build and Release VSIX
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
get-latest-sha:
name: 🔍 Get Latest SHA & Base Version
runs-on: windows-latest
outputs:
version_string: ${{ steps.new_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: blazium-engine/vscode-anko-highlighter
ref: master
fetch-depth: 2
- name: Get Latest Commit SHA
id: get_sha
run: echo "sha=$(git rev-parse HEAD)" >> $ENV:GITHUB_OUTPUT
- name: Generate Changelog.json
id: new_version
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_OWNER: blazium-engine
GITHUB_REPO: vscode-anko-highlighter
BASE_BRANCH: 0acc2206c2a57f104d3295ec4e5b5ce7b7d9d4dd
CURRENT_BRANCH: ${{ steps.get_sha.outputs.sha }}
MAJOR_VERSION: 0
MINOR_VERSION: 0
PATCH_VERSION: 2
run: |
# Ensure the working directory is correct
Set-Location -Path "${{ github.workspace }}"
# Trigger the changelog generation script
node ./scripts/changelog.js $(Get-Location)
# Validate if changelog.json exists
if (-Not (Test-Path -Path "changelog.json")) {
Write-Error "changelog.json not found."
exit 1
}
# Parse changelog.json to extract version information
$changelog = Get-Content -Raw -Path "changelog.json" | ConvertFrom-Json
$major = $changelog.version.major
$minor = $changelog.version.minor
$patch = $changelog.version.patch
# Combine version variables into a single variable
$version = "$major.$minor.$patch"
# Set outputs
echo "version=$version" >> $ENV:GITHUB_OUTPUT
# Create a debug summary
$summary = @(
"# Version Information",
"- Major: $major",
"- Minor: $minor",
"- Patch: $patch",
"- Full Version: $version"
) -join "`n"
echo $summary >> $ENV:GITHUB_STEP_SUMMARY
build:
name: Building VSIX Package
needs: get-latest-sha
runs-on: windows-latest
outputs:
version: ${{ steps.update_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Install dependencies
run: |
cd .\anko\
npm install
- name: Update Package Version
id: update_version
run: |
# Ensure the working directory is correct
Set-Location -Path "${{ github.workspace }}"
# Load the package.json file
$packageJsonPath = "./anko/package.json"
if (-Not (Test-Path -Path $packageJsonPath)) {
Write-Error "package.json not found at $packageJsonPath."
exit 1
}
# Update the version field
$packageJson = Get-Content -Raw -Path $packageJsonPath | ConvertFrom-Json
$packageJson.version = "${{ needs.get-latest-sha.outputs.version_string }}"
# Save the updated package.json
$packageJson | ConvertTo-Json -Depth 10 | Set-Content -Path $packageJsonPath -Encoding utf8
# Log the update
Write-Host "Updated version to $($packageJson.version) in package.json."
echo "version=${{ needs.get-latest-sha.outputs.version_string }}" >> $ENV:GITHUB_OUTPUT
- name: Build VSIX file
run: |
cd .\anko\
vsce package --out ..\dist\blazium-anko-extension-${{ needs.get-latest-sha.outputs.version_string }}.vsix
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: blazium-anko-extension-vsix
path: dist/blazium-anko-extension-${{ needs.get-latest-sha.outputs.version_string }}.vsix
retention-days: 1
release:
name: Deploy Github Release for Anko Highlighter
needs: build
runs-on: windows-latest
permissions:
contents: write # Grants write permissions for content operations
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: blazium-anko-extension-vsix
path: ${{ github.workspace }}\dist
- name: Create GitHub Release
id: createRelease
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.version }}
release_name: Blazium Anko Extension v${{ needs.build.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }}
asset_path: ${{ github.workspace }}\dist\blazium-anko-extension-${{ needs.build.outputs.version }}.vsix
asset_name: blazium-anko-extension-${{ needs.build.outputs.version }}.vsix
asset_content_type: application/octet-stream