on: push: branches: - main jobs: publish: name: Publish VS Code Extension runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get version from package.json id: version run: | VERSION=$(jq -r '.version' dutchies-dcs-scripting-tools/package.json) echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Version: $VERSION" - name: Check if tag exists id: tag_check run: | if git show-ref --verify --quiet "refs/tags/v${{ steps.version.outputs.version }}"; then echo "tag_exists=true" >> $GITHUB_OUTPUT echo "Tag v${{ steps.version.outputs.version }} already exists" else echo "tag_exists=false" >> $GITHUB_OUTPUT echo "Tag v${{ steps.version.outputs.version }} does not exist" fi - name: Exit if tag exists if: steps.tag_check.outputs.tag_exists == 'true' run: | echo "::warning::Tag already exists, exiting." exit 0 - name: Setup Node.js uses: actions/setup-node@v4 if: steps.tag_check.outputs.tag_exists == 'false' with: node-version: '20' - name: Install dependencies if: steps.tag_check.outputs.tag_exists == 'false' run: | cd dutchies-dcs-scripting-tools npm install - name: Build extension if: steps.tag_check.outputs.tag_exists == 'false' run: | cd dutchies-dcs-scripting-tools npm run compile - name: Package extension if: steps.tag_check.outputs.tag_exists == 'false' run: | npm install cd dutchies-dcs-scripting-tools npm install npm run package npx @vscode/vsce package --no-dependencies mv dutchies-dcs-scripting-tools-${{ steps.version.outputs.version }}.vsix ../dutchies-dcs-scripting-tools-${{ steps.version.outputs.version }}.vsix - name: Create tag and release if: steps.tag_check.outputs.tag_exists == 'false' run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git tag "v${{ steps.version.outputs.version }}" git push origin "v${{ steps.version.outputs.version }}" - name: Upload release assets if: steps.tag_check.outputs.tag_exists == 'false' uses: akkuman/gitea-release-action@v1 with: tag_name: v${{ steps.version.outputs.version }} name: Release v${{ steps.version.outputs.version }} body: "VS Code Extension Release" draft: false files: |- dutchies-dcs-scripting-tools-${{ steps.version.outputs.version }}.vsix env: NODE_OPTIONS: '--experimental-fetch'