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
88 changes: 88 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and Comment on PR

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build-and-comment:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get version from manifest
id: get_version
run: |
VERSION=$(jq -r '.version' src/manifest.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Create addon archive
run: |
cd src
VERSION="${{ steps.get_version.outputs.version }}"
zip -r ../dom-time-machine-v${VERSION}.zip .
cd ..

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dom-time-machine-v${{ steps.get_version.outputs.version }}
path: dom-time-machine-v${{ steps.get_version.outputs.version }}.zip
retention-days: 30

- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const version = '${{ steps.get_version.outputs.version }}';
const runId = context.runId;
const repo = context.repo;

// Find and delete previous bot comments
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});

const botComments = comments.data.filter(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🎉 Addon Build Complete')
);

for (const comment of botComments) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}

const comment = `## 🎉 Addon Build Complete

The addon has been successfully built for this PR!

**Version:** \`${version}\`
**Build:** [#${runId}](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})

You can download the built addon from the artifacts section of the workflow run.

### Installation Instructions
1. Download the artifact from the [workflow run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
2. Extract the zip file
3. Load the extension in your browser:
- **Firefox:** Navigate to \`about:debugging#/runtime/this-firefox\`, click "Load Temporary Add-on", and select the manifest.json
- **Chrome:** Navigate to \`chrome://extensions\`, enable "Developer mode", click "Load unpacked", and select the extracted folder
`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
42 changes: 42 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Attach to Release

on:
release:
types: [created]

jobs:
build-and-attach:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get release tag
id: get_tag
run: |
TAG=${GITHUB_REF#refs/tags/}
# Remove 'v' prefix if present
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Update manifest version
run: |
jq --arg version "${{ steps.get_tag.outputs.version }}" \
'.version = $version' src/manifest.json > src/manifest.json.tmp
mv src/manifest.json.tmp src/manifest.json

- name: Create addon archive
run: |
cd src
VERSION="${{ steps.get_tag.outputs.version }}"
zip -r ../dom-time-machine-v${VERSION}.zip .
cd ..

- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
files: dom-time-machine-v${{ steps.get_tag.outputs.version }}.zip
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "DOM Time Machine Pro",
"version": "2.1",
"version": "IN-DEV",
"permissions": [
"storage",
"unlimitedStorage",
Expand Down
Loading