-
Notifications
You must be signed in to change notification settings - Fork 14
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
11 changed files
with
515 additions
and
115 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,128 @@ | ||
name: Release CI | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- v** | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
RUST_BACKTRACE: short | ||
|
||
jobs: | ||
release: | ||
strategy: | ||
matrix: | ||
# os: [windows-latest, ubuntu-latest, macos-latest] | ||
os: [macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
|
||
- name: Rust Cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
workspaces: src-tauri | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install Dependencies (ubuntu only) | ||
if: startsWith(matrix.os, 'ubuntu-') | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf | ||
- name: Reconfigure git to use HTTP authentication | ||
run: > | ||
git config --global url."https://github.com/".insteadOf | ||
ssh://git@github.com/ | ||
- name: Get yarn cache dir path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Yarn Cache | ||
uses: actions/cache@v2 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Yarn install and check | ||
run: | | ||
yarn install --network-timeout 1000000 | ||
yarn run check | ||
- name: Tauri build | ||
uses: tauri-apps/tauri-action@v0 | ||
# enable cache even though failed | ||
# continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | ||
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | ||
with: | ||
tagName: v__VERSION__ | ||
releaseName: "Lanaya v__VERSION__" | ||
releaseBody: "More new features are now supported." | ||
releaseDraft: false | ||
prerelease: true | ||
|
||
# - name: Portable Bundle | ||
# if: matrix.os == 'windows-latest' | ||
# # rebuild with env settings | ||
# run: | | ||
# yarn build | ||
# yarn run portable | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | ||
# TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | ||
# VITE_WIN_PORTABLE: 1 | ||
|
||
release-update: | ||
needs: release | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Reconfigure git to use HTTP authentication | ||
run: > | ||
git config --global url."https://github.com/".insteadOf | ||
ssh://git@github.com/ | ||
- name: Get yarn cache dir path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Yarn Cache | ||
uses: actions/cache@v2 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Yarn install | ||
run: yarn install | ||
|
||
- name: Release updater file | ||
run: yarn run updater | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
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,36 @@ | ||
name: Updater CI | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
release-update: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Reconfigure git to use HTTP authentication | ||
run: > | ||
git config --global url."https://github.com/".insteadOf | ||
ssh://git@github.com/ | ||
- name: Get yarn cache dir path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- name: Yarn Cache | ||
uses: actions/cache@v2 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Yarn install | ||
run: yarn install | ||
|
||
- name: Release updater file | ||
run: yarn run updater | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
All changes will be documented in this file. | ||
|
||
## v0.0.7 | ||
## v0.0.8 | ||
|
||
### Feature | ||
|
||
|
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,98 @@ | ||
/** | ||
* Build and upload assets for macOS(aarch) | ||
*/ | ||
import fs from "fs-extra"; | ||
import path from "path"; | ||
import { exit } from "process"; | ||
import { createRequire } from "module"; | ||
import { getOctokit, context } from "@actions/github"; | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
async function resolve() { | ||
if (!process.env.GITHUB_TOKEN) { | ||
throw new Error("GITHUB_TOKEN is required"); | ||
} | ||
if (!process.env.GITHUB_REPOSITORY) { | ||
throw new Error("GITHUB_REPOSITORY is required"); | ||
} | ||
if (!process.env.TAURI_PRIVATE_KEY) { | ||
throw new Error("TAURI_PRIVATE_KEY is required"); | ||
} | ||
if (!process.env.TAURI_KEY_PASSWORD) { | ||
throw new Error("TAURI_KEY_PASSWORD is required"); | ||
} | ||
|
||
const { version } = require("../package.json"); | ||
|
||
const cwd = process.cwd(); | ||
const bundlePath = path.join(cwd, "src-tauri/target/release/bundle"); | ||
const join = (p) => path.join(bundlePath, p); | ||
|
||
const appPathList = [join("macos/Lanaya.app.tar.gz"), join("macos/Lanaya.app.tar.gz.sig")]; | ||
|
||
for (const appPath of appPathList) { | ||
if (fs.pathExistsSync(appPath)) { | ||
fs.removeSync(appPath); | ||
} | ||
} | ||
|
||
fs.copyFileSync(join("macos/Lanaya.app.tar.gz"), appPathList[0]); | ||
fs.copyFileSync(join("macos/Lanaya.app.tar.gz.sig"), appPathList[1]); | ||
|
||
const options = { owner: context.repo.owner, repo: context.repo.repo }; | ||
const github = getOctokit(process.env.GITHUB_TOKEN); | ||
|
||
const { data: release } = await github.rest.repos.getReleaseByTag({ | ||
...options, | ||
tag: `v${version}`, | ||
}); | ||
|
||
if (!release.id) throw new Error("failed to find the release"); | ||
|
||
await uploadAssets(release.id, [join(`dmg/Lanaya_${version}_aarch64.dmg`), ...appPathList]); | ||
} | ||
|
||
// From tauri-apps/tauri-action | ||
// https://github.com/tauri-apps/tauri-action/blob/dev/packages/action/src/upload-release-assets.ts | ||
async function uploadAssets(releaseId, assets) { | ||
const github = getOctokit(process.env.GITHUB_TOKEN); | ||
|
||
// Determine content-length for header to upload asset | ||
const contentLength = (filePath) => fs.statSync(filePath).size; | ||
|
||
for (const assetPath of assets) { | ||
const headers = { | ||
"content-type": "application/zip", | ||
"content-length": contentLength(assetPath), | ||
}; | ||
|
||
const ext = path.extname(assetPath); | ||
const filename = path.basename(assetPath).replace(ext, ""); | ||
const assetName = path.dirname(assetPath).includes(`target${path.sep}debug`) | ||
? `${filename}-debug${ext}` | ||
: `${filename}${ext}`; | ||
|
||
console.log(`[INFO]: Uploading ${assetName}...`); | ||
|
||
try { | ||
await github.rest.repos.uploadReleaseAsset({ | ||
headers, | ||
name: assetName, | ||
data: fs.readFileSync(assetPath), | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: releaseId, | ||
}); | ||
} catch (error) { | ||
console.log(error.message); | ||
} | ||
} | ||
} | ||
|
||
if (process.platform === "darwin" && process.arch === "arm64") { | ||
resolve(); | ||
} else { | ||
console.error("invalid"); | ||
exit(1); | ||
} |
Oops, something went wrong.