Skip to content

test: ci workflows

test: ci workflows #3

Workflow file for this run

name: Release Management
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
# Manual workflow dispatch for releases
workflow_dispatch:
inputs:
action:
description: 'Action to perform'
required: true
default: 'build'
type: choice
options:
- build
- release
- submit
dryRun:
description: 'Perform dry run (no actual submission)'
default: false
type: boolean
# Comment-triggered releases
issue_comment:
types: [created]
jobs:
# Dry run check on every PR
pr_check:
name: PR Build Check
runs-on: ubuntu-24.04-arm
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check for changesets
id: changeset-check
run: |
if [ -z "$(ls .changeset/*.md 2>/dev/null | grep -v README)" ]; then
echo "hasChangesets=false" >> "$GITHUB_OUTPUT"
echo "⚠️ No changesets found."
else
echo "hasChangesets=true" >> "$GITHUB_OUTPUT"
echo "βœ… Changesets found."
fi
- name: Validate changeset format (if changesets exist)
if: steps.changeset-check.outputs.hasChangesets == 'true'
run: |
echo "Validating changeset format..."
# Check if changesets are properly formatted
git fetch origin main --depth 1
pnpm changeset status
echo "βœ… Changeset format is valid"
- name: Test version bump (dry run)
if: steps.changeset-check.outputs.hasChangesets == 'true'
run: |
echo "Testing version bump..."
# Create a temporary branch to test version bump
git checkout -b temp-version-test
pnpm changeset version
echo "βœ… Version bump test successful"
git checkout -
git branch -D temp-version-test
- name: Build extension (dry run)
run: |
echo "Testing build process..."
pnpm run zip:all
echo "βœ… Build test successful"
- name: Validate build outputs
run: |
echo "Validating build outputs..."
# Check if required files are generated
if [ ! -f "dist/*-chrome.zip" ] && [ ! -f dist/*-chrome.zip ]; then
echo "❌ Chrome build not found"
exit 1
fi
if [ ! -f "dist/*-firefox.zip" ] && [ ! -f dist/*-firefox.zip ]; then
echo "❌ Firefox build not found"
exit 1
fi
if [ ! -f "dist/*-sources.zip" ] && [ ! -f dist/*-sources.zip ]; then
echo "❌ Source build not found"
exit 1
fi
echo "βœ… All required build outputs present"
- name: Test submission format (dry run)
run: |
echo "Testing submission format..."
# Test the submission command in dry run mode
DRY_RUN=true pnpm wxt submit \
--chrome-zip dist/*-chrome.zip \
--firefox-zip dist/*-firefox.zip --firefox-sources-zip dist/*-sources.zip || true
echo "βœ… Submission format test completed"
- name: Comment on PR with check results
uses: actions/github-script@v7
with:
script: |
const hasChangesets = '${{ steps.changeset-check.outputs.hasChangesets }}' === 'true';
let body = '## πŸ” PR Build Check Results\n\n';
body += 'βœ… **All checks passed!** This PR is ready for merge.\n\n';
body += '### Validation Results:\n';
body += '- βœ… Dependencies installed successfully\n';
body += '- βœ… Build process completed without errors\n';
body += '- βœ… All required output files generated\n';
body += '- βœ… Submission format validated\n';
if (hasChangesets) {
body += '- βœ… Changesets found and validated\n';
body += '- βœ… Version bump test successful\n\n';
body += '> **Note**: This PR includes changesets and will trigger a version bump when merged.';
} else {
body += '- ⚠️ No changesets found\n\n';
body += '> **Note**: This PR does not include changesets. No version bump will occur when merged.';
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
- name: Comment on PR with failure results
if: failure()
uses: actions/github-script@v7
with:
script: |
let body = '## ❌ PR Build Check Failed\n\n';
body += '**This PR has build issues that need to be resolved before merging.**\n\n';
body += '### Common Issues:\n';
body += '- Build process failed (check build logs)\n';
body += '- Missing required dependencies\n';
body += '- Invalid changeset format\n';
body += '- Missing required output files\n\n';
body += '> Please check the workflow logs above for specific error details and fix the issues.';
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
# Check if comment triggers a release
check_comment:
name: Check Release Comment
runs-on: ubuntu-24.04-arm
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/release')
outputs:
should_release: ${{ steps.check.outputs.should_release }}
steps:
- name: Check if comment author has permission
id: check
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const { data: collaborator } = await github.rest.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: context.actor
});
const hasPermission = ['admin', 'write'].includes(collaborator.permission);
console.log(`User ${context.actor} has permission: ${hasPermission}`);
if (hasPermission) {
core.setOutput('should_release', 'true');
// Add reaction to comment
await github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});
} else {
core.setOutput('should_release', 'false');
// Add reaction to comment
await github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: 'confused'
});
}
changeset:
name: Version with Changeset
runs-on: ubuntu-24.04-arm
if: |
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
needs: [check_comment]
outputs:
hasChangesets: ${{ steps.changeset-check.outputs.hasChangesets }}
newVersion: ${{ steps.version.outputs.newVersion }}
currentVersion: ${{ steps.current-version.outputs.currentVersion }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# For PR comments, checkout the PR branch
ref: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request.head.ref || github.ref }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Configure Git
run: |
git config user.email "github-actions@users.noreply.github.com"
git config user.name "GitHub Actions"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check for changesets
id: changeset-check
run: |
if [ -z "$(ls .changeset/*.md 2>/dev/null | grep -v README)" ]; then
echo "hasChangesets=false" >> "$GITHUB_OUTPUT"
echo "⚠️ No changesets found. Skipping version bump."
else
echo "hasChangesets=true" >> "$GITHUB_OUTPUT"
echo "βœ… Changesets found. Proceeding with version bump."
fi
- name: Version packages
if: steps.changeset-check.outputs.hasChangesets == 'true'
id: version
run: |
pnpm changeset version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "newVersion=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "πŸ“¦ New version: $NEW_VERSION"
- name: Get current version (if no changesets)
if: steps.changeset-check.outputs.hasChangesets == 'false'
id: current-version
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "currentVersion=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "πŸ“¦ Current version: $CURRENT_VERSION"
# Only auto-commit on push to main
- name: Commit and Push (with version bump)
if: ${{ github.event_name == 'push' && steps.changeset-check.outputs.hasChangesets == 'true' }}
run: |
git add .
git commit -m "chore(release): v$NEW_VERSION"
git tag v$NEW_VERSION
git push
git push --tags
env:
NEW_VERSION: ${{ steps.version.outputs.newVersion }}
# Comment on PR when triggered by comment
- name: Comment on PR - Changeset Results
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const hasChangesets = '${{ steps.changeset-check.outputs.hasChangesets }}' === 'true';
const newVersion = '${{ steps.version.outputs.newVersion }}';
const currentVersion = '${{ steps.current-version.outputs.currentVersion }}';
let body = '## πŸ”„ Changeset Processing Complete\n\n';
if (hasChangesets) {
body += `βœ… **Changesets found and processed**\n`;
body += `πŸ“¦ **New version**: \`v${newVersion}\`\n\n`;
body += `The following changes will be included in the release:\n`;
body += `- Version bumped from previous version to \`v${newVersion}\`\n`;
body += `- Changelog updated with changeset entries\n\n`;
body += `> **Note**: Version changes are staged but not committed yet. The build and release process will continue.`;
} else {
body += `⚠️ **No changesets found**\n`;
body += `πŸ“¦ **Current version**: \`v${currentVersion}\`\n\n`;
body += `No version bump will be performed. This will create a build release instead.\n\n`;
body += `> **Note**: Consider adding a changeset if you want to bump the version for this release.`;
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
build:
name: Build
runs-on: ubuntu-24.04-arm
needs: [changeset]
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request.head.ref || github.ref }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and Zip
run: |
pnpm run zip:all
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: extension-build-${{ github.run_number }}
path: dist/*.zip
if-no-files-found: error
include-hidden-files: true
release:
name: Create Release
runs-on: ubuntu-24.04-arm
needs: [changeset, build]
if: |
(github.event_name == 'workflow_dispatch' && inputs.action == 'release') ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: extension-build-${{ github.run_number }}
path: dist/
- name: Create GitHub Release (with version bump)
if: ${{ needs.changeset.outputs.hasChangesets == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.changeset.outputs.newVersion }}
name: Release v${{ needs.changeset.outputs.newVersion }}
body: |
## Changes
Check the [CHANGELOG.md](./CHANGELOG.md) for detailed changes.
## Extension Files
- Chrome: `amgiflol-${{ needs.changeset.outputs.newVersion }}-chrome.zip`
- Firefox: `amgiflol-${{ needs.changeset.outputs.newVersion }}-firefox.zip`
files: |
dist/*-chrome.zip
dist/*-firefox.zip
draft: false
prerelease: false
- name: Create GitHub Release (no version bump)
if: ${{ needs.changeset.outputs.hasChangesets == 'false' }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.changeset.outputs.currentVersion }}-build-${{ github.run_number }}
name: Build v${{ needs.changeset.outputs.currentVersion }}-build-${{ github.run_number }}
body: |
## Build Release
This is a build release without version changes.
## Extension Files
- Chrome: `amgiflol-${{ needs.changeset.outputs.currentVersion }}-chrome.zip`
- Firefox: `amgiflol-${{ needs.changeset.outputs.currentVersion }}-firefox.zip`
files: |
dist/*-chrome.zip
dist/*-firefox.zip
draft: false
prerelease: true
- name: Comment on PR (if triggered by comment)
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const hasChangesets = '${{ needs.changeset.outputs.hasChangesets }}' === 'true';
const version = hasChangesets ? '${{ needs.changeset.outputs.newVersion }}' : '${{ needs.changeset.outputs.currentVersion }}';
const releaseUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/releases/tag/v${version}${hasChangesets ? '' : '-build-' + context.runNumber}`;
let body = '## πŸš€ Release Created Successfully!\n\n';
body += `πŸ“¦ **Version**: \`v${version}${hasChangesets ? '' : '-build-' + context.runNumber}\`\n`;
body += `πŸ”— **Release URL**: ${releaseUrl}\n\n`;
if (hasChangesets) {
body += `βœ… **Full release** with version bump and changelog updates\n`;
} else {
body += `⚠️ **Build release** without version changes (marked as prerelease)\n`;
}
body += `\nπŸ“ **Extension files are attached to the release**\n`;
body += `- Chrome: \`amgiflol-${version}-chrome.zip\`\n`;
body += `- Firefox: \`amgiflol-${version}-firefox.zip\``;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
submit:
name: Submit to Stores
runs-on: ubuntu-24.04-arm
needs: [changeset, build, release]
if: |
(github.event_name == 'workflow_dispatch' && inputs.action == 'submit') ||
(github.event_name == 'issue_comment' && needs.check_comment.outputs.should_release == 'true')
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: extension-build-${{ github.run_number }}
path: dist/
- name: Submit to stores
run: |
pnpm wxt submit \
--chrome-zip dist/*-chrome.zip \
--firefox-zip dist/*-firefox.zip --firefox-sources-zip dist/*-sources.zip
env:
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dryRun || false }}
CHROME_EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }}
FIREFOX_JWT_ISSUER: ${{ secrets.FIREFOX_JWT_ISSUER }}
FIREFOX_JWT_SECRET: ${{ secrets.FIREFOX_JWT_SECRET }}
EDGE_PRODUCT_ID: ${{ secrets.EDGE_PRODUCT_ID }}
EDGE_CLIENT_ID: ${{ secrets.EDGE_CLIENT_ID }}
EDGE_CLIENT_SECRET: ${{ secrets.EDGE_CLIENT_SECRET }}
EDGE_ACCESS_TOKEN_URL: ${{ secrets.EDGE_ACCESS_TOKEN_URL }}
- name: Comment on PR with submission result
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const dryRun = '${{ github.event_name == 'workflow_dispatch' && inputs.dryRun || false }}' === 'true';
let body = '## πŸ“€ Store Submission ';
body += dryRun ? 'Dry Run Complete' : 'Complete';
body += '\n\n';
if (dryRun) {
body += 'πŸ” **Dry run mode** - No actual submission performed\n';
body += 'βœ… All validation checks passed\n';
body += 'πŸ“‹ Ready for actual submission when you\'re ready\n\n';
body += '> Run the workflow again without dry run to submit to stores.';
} else {
body += 'βœ… **Extension submitted to stores successfully!**\n\n';
body += 'πŸ“± **Submitted to**:\n';
body += '- Chrome Web Store\n';
body += '- Firefox Add-ons (AMO)\n';
body += '- Microsoft Edge Add-ons\n\n';
body += '> Store reviews typically take 1-3 business days. You\'ll receive email notifications about the review status.';
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});