-
Notifications
You must be signed in to change notification settings - Fork 17
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
12 changed files
with
1,256 additions
and
299 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 |
---|---|---|
|
@@ -24,14 +24,14 @@ jobs: | |
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v2.5.1 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.14.0 | ||
node-version: 16 | ||
|
||
- name: Setup Rust | ||
uses: actions-rs/[email protected] | ||
|
@@ -66,4 +66,24 @@ jobs: | |
tagName: ${{ github.ref_name }} | ||
releaseName: ${{ github.ref_name }} | ||
releaseDraft: true | ||
releaseBody: 'See the assets to download this version and install.' | ||
prerelease: false | ||
update: | ||
needs: release | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Create Update | ||
run: yarn update | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
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,72 @@ | ||
import fetch from 'node-fetch' | ||
import { getOctokit, context } from '@actions/github' | ||
|
||
const UPDATE_TAG_NAME = 'updater' | ||
const UPDATE_FILE_NAME = 'update.json' | ||
|
||
const getSignature = async (url) => { | ||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { 'Content-Type': 'application/octet-stream' }, | ||
}) | ||
return response.text() | ||
} | ||
|
||
const updateData = { | ||
name: '', | ||
pub_date: new Date().toISOString(), | ||
platforms: { | ||
win64: { signature: '', url: '' }, | ||
linux: { signature: '', url: '' }, | ||
darwin: { signature: '', url: '' }, | ||
'linux-x86_64': { signature: '', url: '' }, | ||
'windows-x86_64': { signature: '', url: '' }, | ||
}, | ||
} | ||
|
||
const octokit = getOctokit(process.env.GITHUB_TOKEN) | ||
const options = { owner: context.repo.owner, repo: context.repo.repo } | ||
|
||
const { data: release } = await octokit.rest.repos.getLatestRelease(options) | ||
updateData.name = release.tag_name | ||
for (const { name, browser_download_url } of release.assets) { | ||
if (name.endsWith('.msi.zip')) { | ||
updateData.platforms.win64.url = browser_download_url | ||
updateData.platforms['windows-x86_64'].url = browser_download_url | ||
} else if (name.endsWith('.msi.zip.sig')) { | ||
const signature = await getSignature(browser_download_url) | ||
updateData.platforms.win64.signature = signature | ||
updateData.platforms['windows-x86_64'].signature = signature | ||
} else if (name.endsWith('.app.tar.gz')) { | ||
updateData.platforms.darwin.url = browser_download_url | ||
} else if (name.endsWith('.app.tar.gz.sig')) { | ||
const signature = await getSignature(browser_download_url) | ||
updateData.platforms.darwin.signature = signature | ||
} else if (name.endsWith('.AppImage.tar.gz')) { | ||
updateData.platforms.linux.url = browser_download_url | ||
updateData.platforms['linux-x86_64'].url = browser_download_url | ||
} else if (name.endsWith('.AppImage.tar.gz.sig')) { | ||
const signature = await getSignature(browser_download_url) | ||
updateData.platforms.linux.signature = signature | ||
updateData.platforms['linux-x86_64'].signature = signature | ||
} | ||
} | ||
|
||
const { data: updater } = await octokit.rest.repos.getReleaseByTag({ | ||
...options, | ||
tag: UPDATE_TAG_NAME, | ||
}) | ||
|
||
for (const { id, name } of updater.assets) { | ||
if (name === UPDATE_FILE_NAME) { | ||
await octokit.rest.repos.deleteReleaseAsset({ ...options, asset_id: id }) | ||
break | ||
} | ||
} | ||
|
||
await octokit.rest.repos.uploadReleaseAsset({ | ||
...options, | ||
release_id: updater.id, | ||
name: UPDATE_FILE_NAME, | ||
data: JSON.stringify(updateData), | ||
}) |
Oops, something went wrong.