Skip to content

Commit

Permalink
Merge pull request #131 from modos189/manifest_v3_2
Browse files Browse the repository at this point in the history
Manifest V3
  • Loading branch information
modos189 authored May 2, 2024
2 parents b642e3a + f8337b3 commit a864769
Show file tree
Hide file tree
Showing 23 changed files with 1,098 additions and 339 deletions.
63 changes: 54 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- build_script: build_mv2
- build_script: build_mv3_firefox
- build_script: build_mv3_chrome
- build_script: build_mv3_safari
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- name: Install dependencies
run: npm ci
Expand All @@ -29,7 +36,7 @@ jobs:
run: npm run lint

- name: Build
run: npm run build
run: npm run ${{ matrix.build_script }}

- name: Get version from package.json
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -41,34 +48,72 @@ jobs:
- name: Save metadata
run: |
mkdir -p ./build/.metadata
ORIGINAL_FILE_NAME=$(ls artifacts/*.zip)
FILE_NAME="${ORIGINAL_FILE_NAME##*/}"
FILE_NAME="${FILE_NAME%.zip}"
if [ "$GITHUB_EVENT_NAME" = "push" ]; then
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then
mv artifacts/*.zip ./build/iitc-button-${{steps.get-version-key-from-json.outputs.version}}.zip
# Release build
echo "release" > ./build/.metadata/build_type
else
# Beta build from master branch
mv artifacts/*.zip ./build/iitc-button-${{github.sha}}.zip
FILE_NAME="${FILE_NAME}-$(echo ${{ github.sha }} | cut -c 1-6)"
echo "beta" > ./build/.metadata/build_type
fi
echo ${{ github.sha }} > ./build/.metadata/commit
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
mv artifacts/*.zip ./build/iitc-button-${{github.event.pull_request.head.sha}}.zip
# Build artifacts for PR
FILE_NAME="${FILE_NAME}-$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-6)"
echo "PR" > ./build/.metadata/build_type
echo ${{ github.event.pull_request.head.sha }} > ./build/.metadata/commit
fi
echo $( ls ./build/ | grep '.zip' ) > ./build/.metadata/zip_filename
mv $ORIGINAL_FILE_NAME "./build/$FILE_NAME".zip
echo "GITHUB_SHA_SHORT=$(cat ./build/.metadata/commit | cut -c 1-6)" >> $GITHUB_ENV
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v')
env:
FILE_PATH: ./build/${{ env.FILE_NAME }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "./build/iitc-button-${{ steps.get-version-key-from-json.outputs.version }}.zip"
artifacts: ${{ env.FILE_PATH }}
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: iitc-button-${{ env.GITHUB_SHA_SHORT }}-artifact
name: ${{ env.FILE_NAME }}
path: |
./build/
collect:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: collected_artifacts

- name: Move artifacts to final directory
run: |
mkdir -p final_artifacts
echo "Moving contents from artifact directories to final_artifacts directory:"
for dir in collected_artifacts/*; do
if [ -d "$dir" ]; then
cp -rf "$dir"/* "$dir"/.metadata final_artifacts/
fi
done
echo "Contents of final_artifacts directory:"
ls -la final_artifacts/
- name: Get metadata
run: echo "GITHUB_SHA_SHORT=$(cat ./final_artifacts/.metadata/commit | cut -c 1-6)" >> $GITHUB_ENV

- uses: actions/upload-artifact@v4
with:
name: iitc-button-${{ env.GITHUB_SHA_SHORT }}-artifacts
path: final_artifacts/*
52 changes: 39 additions & 13 deletions .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
name: Add artifact links to pull request

on:
workflow_run:
workflows: ['Build IITC Button']
workflows: ["Build IITC Button"]
types: [completed]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
artifacts-url-comments:
if: ${{ github.event.workflow_run.event == 'pull_request' }}
comment-links:
runs-on: ubuntu-latest
steps:
- name: add artifact links to pull request and related issues step
uses: tonyhallett/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get artifact list from API
id: get-artifacts
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const runId = ${{ github.event.workflow_run.id }};
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
artifacts.data.artifacts.forEach((artifact, index) => {
const nameVar = `artifact${index + 1}`;
const urlVar = `url${index + 1}`;
let displayName = artifact.name.endsWith('-artifacts') ? `**${artifact.name}**` : artifact.name;
core.exportVariable(nameVar, displayName);
core.exportVariable(urlVar, `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/artifacts/${artifact.id}`);
});
- name: Comment with artifact links for PR
uses: marocchino/sticky-pull-request-comment@v2
with:
prefix: Here are the build results
suffix: Artifacts will only be retained for 90 days.
format: url
addTo: pull
header: pr_artifacts
number: ${{ github.event.workflow_run.pull_requests[0].number }}
message: |
Build completed successfully. Below are the download links for the build artifacts:
| Artifact Name | Download Link |
| ------------- | ------------- |
| ${{ env.artifact1 }} | [Download](${{ env.url1 }}) |
| ${{ env.artifact2 }} | [Download](${{ env.url2 }}) |
| ${{ env.artifact3 }} | [Download](${{ env.url3 }}) |
| ${{ env.artifact4 }} | [Download](${{ env.url4 }}) |
| ${{ env.artifact5 }} | [Download](${{ env.url5 }}) |
Artifacts will only be retained for 90 days.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ Theoretically, you violates ToS, but as you totally relies on intel.ingress.com
npm install
```

### Compiles and hot-reloads for development
### Compiles and minifies for production with Manifest V2
```
npm run serve
npm run build_mv2
```

### Compiles and minifies for production
### Compiles and minifies for production with Manifest V3
```
npm run build
npm run build_mv3_firefox
# or
npm run build_mv3_chrome
# or
npm run build_mv3_safari
```

### Lints and fixes files
Expand All @@ -59,7 +63,7 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
## Build for Safari (MacOS and iOS)

1. Follow the [general build instructions](#project-setup).
To build for iOS, set the _BROWSER="safari-ios"_ environment variable (example: `BROWSER="safari-ios" npm run build`)
To build for iOS, set the _BROWSER="safari-ios"_ environment variable (example: `BROWSER="safari-ios" npm run build`). Tested only on Manifest V2.

2. Open the Xcode project in the `safari` folder

Expand All @@ -77,4 +81,3 @@ To develop without a certificate, tell Safari to load unsigned extensions using
* Select the Extensions tab. This tab shows the localized description, display name, and version number for the selected Safari App Extension. It also provides more information about the permissions claimed by the extension.
* Find your new extension in the list on the left, and enable it by selecting the checkbox.


92 changes: 46 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
"license": "GPLv3",
"private": true,
"scripts": {
"serve": "vue-cli-service build --mode development --watch",
"build": "vue-cli-service build",
"build_mv2": "export MANIFEST_VERSION=2 && vue-cli-service build",
"build_mv3_firefox": "export MANIFEST_VERSION=3 && export BROWSER=firefox && vue-cli-service build",
"build_mv3_chrome": "export MANIFEST_VERSION=3 && export BROWSER=chrome && vue-cli-service build",
"build_mv3_safari": "export MANIFEST_VERSION=3 && export BROWSER=safari && vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@highlightjs/vue-plugin": "^1.0.2",
"core-js": "^3.8.3",
"highlight.js": "^10.7.3",
"jszip": "^3.10.1",
"lib-iitc-manager": "^1.8.4",
"lib-iitc-manager": "^1.9.0",
"scored-fuzzysearch": "^1.0.5",
"vue": "^2.6.14"
},
Expand Down
15 changes: 15 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,20 @@
},
"saveToJson": {
"message": "Save to json"
},
"alertChromeRequiresDevModeTitle": {
"message": "Our extension requires Developer Mode to be enabled to manage UserScripts, due to Manifest V3 limitations in Chrome. It's easy to enable!"
},
"alertChromeRequiresDevModeButton": {
"message": "Please follow this guide"
},
"alertHostPermissionsRequiredTitle": {
"message": "Provide access to URLs for userscripts to work. You will be able to change your choice in your browser settings."
},
"alertHostPermissionsRequiredButtonIntel": {
"message": "Ingress Intel only"
},
"alertHostPermissionsRequiredButtonAllUrls": {
"message": "All URLs to ensure full support"
}
}
Loading

0 comments on commit a864769

Please sign in to comment.