chore: fix #46
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- 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 | |
- 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" | |
- 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 mcfunction.tmLanguage.json | |
git commit -m "🤖 Bump version" | |
git push origin main | |
- 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 }} |