Updated references to Chrome, Microsoft Edge, and Chromium-based browsers in workflow and README to improve clarity. Installation steps and file descriptions now more accurately reflect supported browsers and manual installation options.
203 lines
7.4 KiB
YAML
203 lines
7.4 KiB
YAML
name: Publish Extension to Multiple Stores
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*" # Triggers on version tags like v1.0.0, v1.2.3, etc.
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "18"
|
|
|
|
- name: Validate manifest.json
|
|
run: |
|
|
# Validate that manifest.json is valid JSON
|
|
node -e "JSON.parse(require('fs').readFileSync('manifest.json', 'utf8'))"
|
|
echo "✅ manifest.json is valid"
|
|
|
|
- name: Extract version from tag
|
|
id: version
|
|
run: |
|
|
# Extract version from git tag (remove 'v' prefix if present)
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
VERSION=${VERSION#v}
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Extracted version: $VERSION"
|
|
|
|
- name: Update manifest version
|
|
run: |
|
|
# Update version in manifest.json to match the tag
|
|
node -e "
|
|
const fs = require('fs');
|
|
const manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
|
|
manifest.version = '${{ steps.version.outputs.version }}';
|
|
fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2));
|
|
console.log('Updated manifest.json version to:', manifest.version);
|
|
"
|
|
|
|
- name: Update package.json version
|
|
run: |
|
|
# Update version in package.json to match the tag
|
|
node -e "
|
|
const fs = require('fs');
|
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
pkg.version = '${{ steps.version.outputs.version }}';
|
|
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
|
console.log('Updated package.json version to:', pkg.version);
|
|
"
|
|
|
|
- name: Create extension packages
|
|
run: |
|
|
# Create Chrome extension zip
|
|
zip -r chrome-extension.zip . \
|
|
-x "*.git*" \
|
|
-x "node_modules/*" \
|
|
-x ".github/*" \
|
|
-x "*.md" \
|
|
-x "LICENSE" \
|
|
-x "*.zip" \
|
|
-x "*.crx"
|
|
|
|
# Create Microsoft Edge extension zip (same as Chrome for MV3)
|
|
cp chrome-extension.zip edge-extension.zip
|
|
|
|
echo "📦 Created extension packages"
|
|
ls -la *.zip
|
|
|
|
- name: Create CRX file for GitHub release
|
|
run: |
|
|
# Install chrome-extension-packer
|
|
npm install -g crx3
|
|
|
|
# Create private key for CRX signing (for distribution only)
|
|
openssl genrsa -out key.pem 2048
|
|
|
|
# Verify manifest.json exists
|
|
ls -la manifest.json
|
|
echo "Current directory: $(pwd)"
|
|
echo "Contents:"
|
|
ls -la
|
|
|
|
# Create temporary directory for extension files
|
|
mkdir -p extension-temp
|
|
|
|
# Copy extension files to temp directory
|
|
cp manifest.json extension-temp/
|
|
cp background.js extension-temp/
|
|
cp content.js extension-temp/
|
|
cp popup.html extension-temp/
|
|
cp popup.js extension-temp/
|
|
cp -r icons extension-temp/
|
|
|
|
# Verify temp directory contents
|
|
echo "Extension temp directory contents:"
|
|
ls -la extension-temp/
|
|
|
|
# Create CRX file from temp directory
|
|
cd extension-temp
|
|
crx3 -o ../extension.crx -p ../key.pem .
|
|
cd ..
|
|
|
|
echo "📦 Created extension.crx"
|
|
ls -la extension.crx
|
|
|
|
# Clean up
|
|
rm -rf extension-temp
|
|
|
|
- name: Publish to Chrome Web Store
|
|
continue-on-error: true
|
|
id: chrome-publish
|
|
uses: mnao305/chrome-extension-upload@v5.0.0
|
|
with:
|
|
file-path: chrome-extension.zip
|
|
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
|
|
client-id: ${{ secrets.CHROME_CLIENT_ID }}
|
|
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
|
|
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
|
|
publish: true # Set to false if you want to upload without publishing
|
|
|
|
- name: Publish to Microsoft Edge Add-ons
|
|
continue-on-error: true
|
|
id: edge-publish
|
|
uses: wdzeng/edge-addon@v2
|
|
with:
|
|
product-id: ${{ secrets.EDGE_PRODUCT_ID }}
|
|
zip-path: edge-extension.zip
|
|
api-key: ${{ secrets.EDGE_API_KEY }}
|
|
client-id: ${{ secrets.EDGE_CLIENT_ID }}
|
|
notes-for-certification: "Automatic release v${{ steps.version.outputs.version }} - ${{ github.sha }}"
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: |
|
|
chrome-extension.zip
|
|
edge-extension.zip
|
|
extension.crx
|
|
generate_release_notes: true
|
|
body: |
|
|
## Xget for Chrome v${{ steps.version.outputs.version }}
|
|
|
|
This release has been automatically published to multiple extension stores.
|
|
|
|
### 📦 Installation Options
|
|
|
|
- **Chrome Web Store**: [Install from Chrome Web Store](https://chromewebstore.google.com/detail/ajiejgobfcifcikbahpijopolfjoodgf)
|
|
- **Microsoft Edge Add-ons**: [Install from Microsoft Edge Add-ons](https://microsoftedge.microsoft.com/addons/detail/hbfflpongojnfojbgadppjgnkabkpjea)
|
|
- **Manual Installation**: Download the files below or see the [Installation Guide](https://github.com/xixu-me/Xget-for-Chrome?tab=readme-ov-file#-installation) for detailed instructions
|
|
|
|
### 📁 Available Files
|
|
|
|
- `chrome-extension.zip` - For Chrome browsers
|
|
- `edge-extension.zip` - For Microsoft Edge
|
|
- `extension.crx` - Pre-packaged extension file for all Chromium-based browsers
|
|
|
|
### Changes
|
|
- See commit history for detailed changes
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Check publication results
|
|
run: |
|
|
echo "📊 Publication Results Summary:"
|
|
echo "================================"
|
|
|
|
if [ "${{ steps.chrome-publish.outcome }}" = "success" ]; then
|
|
echo "✅ Chrome Web Store: Successfully published"
|
|
elif [ "${{ steps.chrome-publish.outcome }}" = "failure" ]; then
|
|
echo "❌ Chrome Web Store: Publication failed"
|
|
else
|
|
echo "⚠️ Chrome Web Store: Skipped (missing secrets)"
|
|
fi
|
|
|
|
if [ "${{ steps.edge-publish.outcome }}" = "success" ]; then
|
|
echo "✅ Microsoft Edge Add-ons: Successfully published"
|
|
elif [ "${{ steps.edge-publish.outcome }}" = "failure" ]; then
|
|
echo "❌ Microsoft Edge Add-ons: Publication failed"
|
|
else
|
|
echo "⚠️ Microsoft Edge Add-ons: Skipped (missing secrets)"
|
|
fi
|
|
|
|
echo "✅ GitHub Release: Created with extension files"
|
|
echo "================================"
|
|
|
|
- name: Notify success
|
|
run: |
|
|
echo "🎉 Successfully published Xget for Chrome v${{ steps.version.outputs.version }} to multiple stores!"
|
|
echo "🔗 Chrome Web Store: https://chrome.google.com/webstore/detail/${{ secrets.CHROME_EXTENSION_ID }}"
|
|
echo "🔗 Microsoft Edge Add-ons: Check the releases page for manual installation files"
|
|
echo "📦 GitHub Release: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}"
|