-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:Postcatlab/postcat
- Loading branch information
Showing
5 changed files
with
202 additions
and
103 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,91 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
# branches: [feat/xxx] | ||
tags: | ||
- 'v*.*.*' | ||
jobs: | ||
release: | ||
name: build and release electron app | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows-latest, macos-12, ubuntu-latest] | ||
|
||
steps: | ||
- name: Check out git repository | ||
uses: actions/[email protected] | ||
|
||
- name: Install Node.js | ||
uses: actions/[email protected] | ||
with: | ||
node-version: '16' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v3 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install | ||
run: | | ||
yarn install --frozen-lockfile | ||
echo "${{ secrets.QINIU_ENV_JS }}" > qiniu_env.js | ||
- name: Release for Windows | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
yarn release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Release for MacOS | ||
if: matrix.os == 'macos-12' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | ||
P12_PASSWORD: ${{ secrets.P12_PASSWORD }} | ||
# BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} | ||
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | ||
run: | | ||
# create variables | ||
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | ||
# PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | ||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | ||
# import certificate and provisioning profile from secrets | ||
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH | ||
# echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH | ||
# create temporary keychain | ||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | ||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
# import certificate to keychain | ||
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | ||
security list-keychain -d user -s $KEYCHAIN_PATH | ||
# apply provisioning profile | ||
# mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | ||
# cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | ||
echo "${{ secrets.NOTARIZE_JS }}" > scripts/notarize.js | ||
yarn release | ||
# clean up keychain and provisioning profile | ||
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db | ||
- name: Release for Linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
yarn release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
name: Release | ||
|
||
# github release event list: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release | ||
|
||
on: | ||
push: | ||
# branches: [feat/v0.1.0] | ||
tags: | ||
- 'v*.*.*' | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
release: | ||
name: build and release electron app | ||
name: Qi niu published | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows-latest, macos-12, ubuntu-latest] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- name: Check out git repository | ||
|
@@ -24,68 +25,9 @@ jobs: | |
with: | ||
node-version: '16' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v3 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install | ||
run: | | ||
yarn install --frozen-lockfile | ||
echo "${{ secrets.QINIU_ENV_JS }}" > qiniu_env.js | ||
- name: Release for Windows | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
yarn release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Release for MacOS x86 | ||
if: matrix.os == 'macos-12' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | ||
P12_PASSWORD: ${{ secrets.P12_PASSWORD }} | ||
# BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} | ||
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | ||
run: | | ||
# create variables | ||
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | ||
# PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | ||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | ||
# import certificate and provisioning profile from secrets | ||
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH | ||
# echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH | ||
# create temporary keychain | ||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | ||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
# import certificate to keychain | ||
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | ||
security list-keychain -d user -s $KEYCHAIN_PATH | ||
# apply provisioning profile | ||
# mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | ||
# cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | ||
echo "${{ secrets.NOTARIZE_JS }}" > scripts/notarize.js | ||
yarn release | ||
# clean up keychain and provisioning profile | ||
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db | ||
- name: Release for Linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
yarn release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
npm i -g [email protected] | ||
echo "${{ secrets.QINIU_ENV_JS }}" > qiniu_env.js | ||
node publish.js |
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ out/ | |
!*.config.js | ||
!.*.js | ||
!upload.js | ||
!publish.js | ||
|
||
# dependencies | ||
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,63 @@ | ||
const qiniu = require('qiniu'); | ||
const package = require('./package.json'); | ||
const { AK, SK, bucket } = require('./qiniu_env.js'); | ||
|
||
qiniu.conf.ACCESS_KEY = AK; | ||
qiniu.conf.SECRET_KEY = SK; | ||
|
||
const toLatest = name => name.replace(/\d+\.\d+\.\d+/, 'latest'); | ||
const onlyName = name => name.replace(/release\//, ''); | ||
|
||
// * 构建客户端实例 | ||
const client = new qiniu.rs.Client(); | ||
|
||
// * 删除单个文件 | ||
const removeFile = (spaceName, file) => | ||
new Promise(resolve => { | ||
client.remove(spaceName, file, (err, ret) => (err ? resolve(false) : resolve(true))); | ||
}); | ||
|
||
// * 拷贝单个文件 | ||
const cpFile = (fromFile, toFile) => | ||
new Promise(resolve => { | ||
client.copy(bucket, fromFile, bucket, toFile, err => (err ? resolve(false) : resolve(true))); | ||
}); | ||
|
||
const version = package.version; | ||
const fileList = [ | ||
'release/Postcat-Setup-?.exe', | ||
'release/Postcat-?-arm64.dmg', | ||
'release/Postcat-?-arm64-mac.zip', | ||
'release/Postcat-?.dmg', | ||
'release/Postcat-?-mac.zip', | ||
'release/Postcat-?.AppImage', | ||
'release/latest.yml', | ||
'release/latest-linux.yml', | ||
'release/latest-mac.yml' | ||
].map(it => it.replace(/\?/, `${version}`)); | ||
|
||
const main = async () => { | ||
const deleteResult = await Promise.all( | ||
fileList.map(async it => { | ||
const isOK = await removeFile(bucket, `download/latest/${toLatest(onlyName(it))}`); | ||
return Promise.resolve(isOK || false); | ||
}) | ||
); | ||
console.log('删除latest文件结果', deleteResult); | ||
const copyFile = await Promise.all( | ||
fileList.map(async it => { | ||
const isOK = await cpFile(`download/${version}/${onlyName(it)}`, `download/latest/${toLatest(onlyName(it))}`); | ||
return Promise.resolve(isOK || false); | ||
}) | ||
); | ||
console.log('拷贝latest文件结果', copyFile); | ||
const copyYml = await Promise.all( | ||
fileList.map(async it => { | ||
const isOK = await cpFile(`download/${version}/${onlyName(it)}`, `download/latest/${onlyName(it)}`); | ||
return Promise.resolve(isOK || false); | ||
}) | ||
); | ||
console.log('拷贝版本文件结果', copyYml); | ||
}; | ||
|
||
main(); |
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