docs: update README #60
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: | |
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 | |
npm install -g plist2 | |
- name: "Setup jq" | |
uses: dcarbone/install-jq-action@v2 | |
with: | |
version: 1.7 | |
force: true | |
# --------------------------------------------- | |
# ---- generate files ----- | |
# --------------------------------------------- | |
- name: Export YAML -> JSON -> PLIST | |
run: | | |
js-yaml mcfunction.tmLanguage.yaml > mcfunction.tmLanguage.json | |
plist2 mcfunction.tmLanguage.json mcfunction.tmLanguage | |
- 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 mcfunction.tmLanguage | |
git commit -m "🤖 Generate JSON/PLIST" | |
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.tmp | |
mv package.json.tmp package.json | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git add package.json | |
git commit -m "🎉 Release ${{ steps.version.outputs.v }}" | |
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: | | |
*.vsix | |
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 vsce | |
if: startsWith(github.ref, 'refs/tags/') | |
run: vsce publish | |
- name: Release to openvsix | |
if: startsWith(github.ref, 'refs/tags/') | |
run: npx ovsx publish ${{ steps.version.outputs.ext }} -p ${{ secrets.OVSX }} |