Publish extension packages to releases

Rewrite package-extensions workflow to publish built extension artifacts directly to GitHub Releases instead of uploading Actions artifacts. Changes include: enable Node 24 for JS actions, add workflow_dispatch input (release_tag), resolve release tag at runtime, upgrade actions/checkout to v5 and set contents permission to write, produce dist/release/*.zip/.xpi, remove artifact uploads, create/reuse release and upload assets with gh, and write a workflow summary. README updated to document the new release-based publishing flow and Node/checkout changes.
This commit is contained in:
jonny
2026-04-22 19:04:57 +08:00
parent d307741f1f
commit cf75f087a7
2 changed files with 42 additions and 23 deletions
+36 -19
View File
@@ -1,7 +1,14 @@
name: Package Extensions
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
workflow_dispatch:
inputs:
release_tag:
description: Release tag used for direct asset upload, for example v2026.04.23
required: true
push:
tags:
- 'v*'
@@ -10,10 +17,20 @@ jobs:
package:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Resolve release tag
id: release
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag='${{ github.event.inputs.release_tag }}'
else
tag='${{ github.ref_name }}'
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Read extension versions
id: versions
@@ -35,28 +52,28 @@ jobs:
- name: Build package files
run: |
mkdir -p dist/store dist/offline
mkdir -p dist/release
pushd chrome >/dev/null
zip -qr "../dist/store/memos-bber-chrome-webstore-${{ steps.versions.outputs.chrome_version }}.zip" .
zip -qr "../dist/offline/memos-bber-chrome-offline-${{ steps.versions.outputs.chrome_version }}.zip" .
zip -qr "../dist/release/memos-bber-chrome-${{ steps.versions.outputs.chrome_version }}.zip" .
popd >/dev/null
pushd firefox >/dev/null
zip -qr "../dist/store/memos-bber-firefox-amo-${{ steps.versions.outputs.firefox_version }}.xpi" .
zip -qr "../dist/offline/memos-bber-firefox-offline-${{ steps.versions.outputs.firefox_version }}.xpi" .
zip -qr "../dist/release/memos-bber-firefox-${{ steps.versions.outputs.firefox_version }}.xpi" .
popd >/dev/null
- name: Upload store packages
uses: actions/upload-artifact@v4
with:
name: store-packages
path: dist/store/*
if-no-files-found: error
- name: Publish release assets
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
tag='${{ steps.release.outputs.tag }}'
gh release view "$tag" >/dev/null 2>&1 || \
gh release create "$tag" --title "$tag" --notes "Automated extension packages"
gh release upload "$tag" dist/release/* --clobber
- name: Upload offline packages
uses: actions/upload-artifact@v4
with:
name: offline-packages
path: dist/offline/*
if-no-files-found: error
- name: Write workflow summary
run: |
tag='${{ steps.release.outputs.tag }}'
echo "## Release assets" >> "$GITHUB_STEP_SUMMARY"
echo "- Chrome: https://github.com/${{ github.repository }}/releases/download/$tag/memos-bber-chrome-${{ steps.versions.outputs.chrome_version }}.zip" >> "$GITHUB_STEP_SUMMARY"
echo "- Firefox: https://github.com/${{ github.repository }}/releases/download/$tag/memos-bber-firefox-${{ steps.versions.outputs.firefox_version }}.xpi" >> "$GITHUB_STEP_SUMMARY"
+6 -4
View File
@@ -8,12 +8,14 @@
## 打包
仓库内置了 GitHub Actions 工作流 [package-extensions.yml](.github/workflows/package-extensions.yml),支持手动触发或在推送 `v*` 标签时自动打包。
仓库内置了 GitHub Actions 工作流 [package-extensions.yml](.github/workflows/package-extensions.yml),支持手动触发或在推送 `v*` 标签时自动打包并发布到 GitHub Releases
- `store-packages`:商店上传用文件,包含 Chrome 的 zip 包和 Firefox 的 xpi 包。
- `offline-packages`:离线分发用文件,包含 Chrome 的 zip 包和 Firefox 的 xpi 包
- 推送 `v*` 标签时:自动把 Chrome 的 zip 包和 Firefox 的 xpi 包上传为对应 Release 的 assets
- 手动触发时:需要填写 `release_tag`,工作流会把产物直接上传到这个 tag 对应的 Release
- 下载时拿到的是文件本体,不再通过 Actions artifact 额外包一层 zip。
- 打包源码固定来自 `main` 分支;`tag` 只用于决定上传到哪个 Release。
说明:Chrome 的离线包用于解压后在开发者模式中“加载已解压的扩展程序”;Firefox 的离线包为未签名 xpi,适合临时附加组件或自行签名后的分发场景
说明:Chrome 的 zip 包可用于商店上传,Firefox 的 xpi 包可用于 AMO 上传或离线分发。工作流已显式启用 Node 24 运行 JavaScript actions,并使用新的 `actions/checkout@v5`
## 更新日志
- 20260422 调整发送设置,支持仅发送附件