Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Publish

# Tag pushes only: `git push origin v0.5.0`. The publisher's Trusted Publishing
# policy must name this repository and this workflow file; no PAT is stored here.
on:
push:
tags:
- 'v[0-9]*'

# The workflow-level block stays read-only. The publish job is the only job,
# and it needs the two write permissions, so they are declared on the job --
# a workflow-level `write` grants that scope to every job in the file.
permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write # Create the GitHub Release and upload the VSIX to it.
id-token: write # Mint the OIDC token for Marketplace Trusted Publishing.
defaults:
run:
working-directory: VSC-plugin-MD2Docx-Converter
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The release is created from the tag, so the tag has to be fetched.
fetch-depth: 0

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
cache: npm
cache-dependency-path: VSC-plugin-MD2Docx-Converter/package-lock.json

- name: Install Pandoc
# The E2E suite exports every profile against the real pandoc.
run: sudo apt-get update && sudo apt-get install -y pandoc

- name: Check the tag matches the extension version
run: |
version="$(node -p "require('./package.json').version")"
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $version."
exit 1
fi

- name: Check the Dify plugin carries the same version
# The VS Code extension and the Dify plugin share one release version
# line, so a tag that only moved one of them would publish a VSIX whose
# plugin counterpart does not exist yet.
run: |
extension="$(node -p "require('./package.json').version")"
plugin="$(grep -m1 -E '^version:' ../dify-plugin-MD2Docx/manifest.yaml | tr -d '"' | awk '{print $2}')"
meta="$(grep -m1 -E '^ version:' ../dify-plugin-MD2Docx/manifest.yaml | tr -d '"' | awk '{print $2}')"
if [ "$plugin" != "$extension" ] || [ "$meta" != "$extension" ]; then
echo "::error::Version mismatch: extension $extension, manifest.yaml $plugin, meta.version $meta."
exit 1
fi

- run: npm ci

- run: npm test

- name: Run real-Pandoc profile exports
run: npm run test:e2e

- name: Build the VSIX
run: npm run package

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mdocx-converter-${{ github.ref_name }}
path: VSC-plugin-MD2Docx-Converter/*.vsix
if-no-files-found: error

- name: Publish to the Visual Studio Marketplace
# Pin the publisher so a devDependency bump cannot silently change the
# release path. --skip-duplicate keeps a re-run idempotent: if the version
# is already published, the desired end state is already reached.
run: >-
npx --yes @vscode/vsce@4.1.1 publish
--oidc
--skip-duplicate
--packagePath "mdocx-converter-${GITHUB_REF_NAME#v}.vsix"

- name: Attach the VSIX to a GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
notes="$(awk -v ver="${GITHUB_REF_NAME#v}" 'index($0, "### Changes in " ver) == 1 { found = 1; next } found && /^### / { exit } found { print }' README.md)"
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" "mdocx-converter-${GITHUB_REF_NAME#v}.vsix" --clobber
else
gh release create "$GITHUB_REF_NAME" "mdocx-converter-${GITHUB_REF_NAME#v}.vsix" \
--verify-tag \
--title "MD2Docx Converter $GITHUB_REF_NAME" \
--notes "${notes:-MD2Docx Converter $GITHUB_REF_NAME}"
fi
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The Dify `.difypkg` cannot be built with the `dify-plugin` CLI — it is not on

## Releasing

- **VS Code extension**: `npm run package` → `.vsix` in `VSC-plugin-MD2Docx-Converter/`. Publishing needs an Azure DevOps PAT for the `alexmultiagent` publisher — it is **not stored on this machine**, so the last step has to be run by the user (`npx vsce publish --pat <PAT> --no-git-tag-version`). The release tag is separate and optional: `v0.1.0` and `v0.4.0` carry one, 0.2.0, 0.3.0 and 0.4.1 shipped untagged. 0.4.1 is the last version on the Marketplace (published 2026-11-17) — the Marketplace rejects a republished version number.
- **VS Code extension**: `npm run package` → `.vsix` in `VSC-plugin-MD2Docx-Converter/`. Publishing is **automated**: `.github/workflows/publish.yml` fires on a `v*` tag push, re-runs the unit tests and the real-Pandoc E2E exports, builds the VSIX, publishes it through Marketplace **Trusted Publishing** (`npx @vscode/vsce@4.1.1 publish --oidc` — no PAT is stored anywhere), and attaches the same VSIX to a GitHub Release. The publisher's Trusted Publishing policy must name this repository and this workflow file. The workflow refuses to publish unless the tag equals the extension version **and** `dify-plugin-MD2Docx/manifest.yaml` carries the same version — the two products share one version line, so a tag that moved only one of them would ship a VSIX whose plugin counterpart does not exist. Historical tags: `v0.1.0` and `v0.4.0` carry one, 0.2.0, 0.3.0 and 0.4.1 shipped untagged. 0.4.1 is the last version on the Marketplace (published 2026-11-17) — the Marketplace rejects a republished version number.
- **Dify plugin**: a `.difypkg` committed to `AlexMultiAgent/md2docx/` in the `AlexMultiAgent/dify-plugins` fork, pulled into upstream with a PR. One version-update PR = one `.difypkg` file. **The manifest version must be incremented** — the marketplace keys a release by it and rejects a resubmission that reuses or lowers the version. 0.0.5 is published (PR #3797, merged 2026-11-17). The rules are in `dify-plugin-MD2Docx/CLAUDE.md`.
- ⚠️ **Both products share one version line.** `VSC-plugin-MD2Docx-Converter/package.json` and `dify-plugin-MD2Docx/manifest.yaml` carry the **same** version, and a release bumps both. The unified line starts at **0.5.0** (2026-11-18), skipping the previously planned 0.4.2 and 0.0.6 — 0.5.0 is what `package.json` and `manifest.yaml` already say.

Expand Down
Loading