-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Check for Affinity updates | ||
|
||
on: | ||
schedule: | ||
- cron: 0 0 * * * # daily | ||
workflow_dispatch: | ||
|
||
jobs: | ||
get-current-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current-version: ${{ steps.get-version.outputs.current-version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v27 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- id: get-version | ||
run: | | ||
echo "current-version=$(nix eval --impure --json --expr 'let nixpkgs = import <nixpkgs> {}; source = nixpkgs.callPackage ./source.nix {}; in source._version')" >> $GITHUB_OUTPUT | ||
get-live-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
live-version: ${{ steps.get-version.outputs.live-version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- run: npm ci | ||
working-directory: ./grab | ||
- name: Install Playwright Browsers | ||
working-directory: ./grab | ||
run: npx playwright install --with-deps | ||
- id: get-version | ||
working-directory: ./grab | ||
run: | | ||
echo "live-version=$(npx ts-node grab.ts version)" >> $GITHUB_OUTPUT | ||
grab-newest: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- get-live-version | ||
- get-current-version | ||
if: ${{ needs.get-live-version.outputs.live-version != needs.get-current-version.outputs.current-version }} | ||
permissions: | ||
issues: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v27 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- run: sudo apt install -y wget2 | ||
- run: mkdir -p grab/out | ||
- run: npm ci | ||
working-directory: ./grab | ||
- name: Install Playwright Browsers | ||
working-directory: ./grab | ||
run: npx playwright install --with-deps | ||
- id: download-photo | ||
working-directory: ./grab/out | ||
run: | | ||
wget2 --cut-file-get-vars $(npx ts-node ../grab.ts photo) | ||
- id: download-designer | ||
working-directory: ./grab/out | ||
run: | | ||
wget2 --cut-file-get-vars $(npx ts-node ../grab.ts designer) | ||
- id: download-publisher | ||
working-directory: ./grab/out | ||
run: | | ||
wget2 --cut-file-get-vars $(npx ts-node ../grab.ts publisher) | ||
- id: hash-photo | ||
working-directory: ./grab/out | ||
run: | | ||
echo "photo-hash=$(nix-hash --type sha256 ./affinity-photo-msi-*.exe)" >> $GITHUB_OUTPUT | ||
- id: hash-designer | ||
working-directory: ./grab/out | ||
run: | | ||
echo "designer-hash=$(nix-hash --type sha256 ./affinity-designer-msi-*.exe)" >> $GITHUB_OUTPUT | ||
- id: hash-publisher | ||
working-directory: ./grab/out | ||
run: | | ||
echo "publisher-hash=$(nix-hash --type sha256 ./affinity-publisher-msi-*.exe)" >> $GITHUB_OUTPUT | ||
- name: Create Issue | ||
run: | | ||
new_issue_url=$(gh issue create \ | ||
--title "bump suite version ${{needs.get-current-version.current-version}} > ${{needs.get-live-version}}" \ | ||
--assignee "mrshmllow" \ | ||
--label "update" \ | ||
--body "$BODY") | ||
env: | ||
BODY: | | ||
## new hashes | ||
photo `${{ steps.hash-photo.outputs.photo-hash}}` | ||
designer `${{ steps.hash-designer.outputs.designer-hash}}` | ||
publisher `${{ steps.hash-designer.outputs.publisher-hash}}` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { chromium, devices } from 'playwright'; | ||
import assert from 'node:assert'; | ||
|
||
(async () => { | ||
const browser = await chromium.launch(); | ||
const context = await browser.newContext(); | ||
const page = await context.newPage(); | ||
|
||
const arg = process.argv[2]; | ||
let edition = arg; | ||
|
||
if (arg === "version") { | ||
edition = "photo"; | ||
} | ||
|
||
await page.goto(`https://store.serif.com/en-gb/update/windows/${edition}/2/`); | ||
|
||
const span = await page.locator("a", {has: page.locator('span:has-text("MSI/EXE (x64) ")')}); | ||
const link = await span.getAttribute("href"); | ||
|
||
await browser.close(); | ||
|
||
if (arg === "version" && link) { | ||
const regex = /\d+\.\d+\.\d+/; | ||
const match = link.match(regex); | ||
|
||
if (!match) return; | ||
|
||
console.log(`"${match[0]}"`); | ||
|
||
return; | ||
} | ||
|
||
console.log(link); | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"playwright": "1.40.0", | ||
"ts-node": "^10.9.2" | ||
} | ||
} |
Oops, something went wrong.