Skip to content

chore: fix

chore: fix #50

Workflow file for this run

name: Publish
on:
pull_request:
branches: [main]
paths:
- "mcfunction.*"
push:
branches: [main]
tags: ["v*.*.*"]
jobs:
ci:
runs-on: ubuntu-latest
steps:
# ---------------------------------------------
# ----- gather repo -----
# ---------------------------------------------
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Fetch all branches and tags
- name: Fetch all branches and tags
run: git fetch --all
- name: Checkout main branch
run: git checkout main
# ---------------------------------------------
# ----- setup deps -----
# ---------------------------------------------
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: npm
- name: Install npm stuff
run: |
npm install -g @vscode/vsce
npm install -g js-yaml
npm install -g ovsx
# ---------------------------------------------
# ----- generate files -----
# ---------------------------------------------
- name: Export JSON from YAML
run: js-yaml mcfunction.tmLanguage.yaml > mcfunction.tmLanguage.json
- id: version
name: Version
run: |
VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
echo "v=$VERSION" >> "$GITHUB_OUTPUT"
echo "ext=syntax-mcfunction-$VERSION.vsix" >> "$GITHUB_OUTPUT"
# ---------------------------------------------
# ----- push files -----
# ---------------------------------------------
- name: Push JSON to repo for sublime (if not matched)
if: github.ref == 'refs/heads/main'
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add mcfunction.tmLanguage.json
git commit -m "🤖 Generate JSON"
git push origin main
continue-on-error: true
- name: Push version number to repo
if: startsWith(github.ref, 'refs/tags/')
run: |
jq '.version = "${{ steps.version.outputs.v }}"' package.json > package.json
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add package.json
git commit -m "🤖 Bump version"
git push origin main
# ---------------------------------------------
# ----- release -----
# ---------------------------------------------
- id: package
name: Package VSCode Ext
run: vsce package
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: "!startsWith(github.ref, 'refs/tags/')"
with:
name: dist-without-markdown
path: |
"${{ steps.version.outputs.ext }}"
"mcfunction.tmLanguage.yaml"
"mcfunction.tmLanguage.json"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
"*.vsix"
"mcfunction.tmLanguage.yaml"
"mcfunction.tmLanguage.json"
- name: Release to openvsix
if: startsWith(github.ref, 'refs/tags/')
run: npx ovsx publish ${{ steps.version.outputs.ext }} -p ${{ secrets.OVSX }}