n-link/.github/workflows/release.yml

118 lines
4 KiB
YAML
Raw Normal View History

2020-09-27 18:45:54 +00:00
name: "publish"
on:
2020-09-27 19:02:07 +00:00
push:
branches:
- release
2020-09-27 18:45:54 +00:00
jobs:
2020-09-27 21:12:08 +00:00
create-release:
runs-on: ubuntu-latest
outputs:
RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}
RELEASE_UPLOAD_URL: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
- name: Install GNU tar
if: runner.os == 'macOS'
run: |
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
2020-09-27 21:12:08 +00:00
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 12
- name: get version
2020-11-23 00:01:41 +00:00
run: echo "PACKAGE_VERSION=$(node -p "require('./desktop/package.json').version")" >> $GITHUB_ENV
2020-09-27 21:12:08 +00:00
- name: create release
id: create_release
uses: actions/create-release@v1.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.PACKAGE_VERSION }}
release_name: "N-Link v${{ env.PACKAGE_VERSION }}"
body: "See the assets to download this version and install."
draft: true
prerelease: false
2020-09-27 18:45:54 +00:00
publish-tauri:
2020-09-27 21:12:08 +00:00
needs: create-release
2020-09-27 18:45:54 +00:00
strategy:
fail-fast: false
matrix:
2020-09-27 21:12:08 +00:00
platform: [ macos-latest, ubuntu-18.04, windows-latest ]
2020-09-27 18:45:54 +00:00
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
2020-09-27 19:06:23 +00:00
key: ${{ matrix.platform }}-yarn-${{ hashFiles('**/yarn.lock') }}
2020-09-27 18:45:54 +00:00
restore-keys: |
2020-09-27 19:08:00 +00:00
${{ matrix.platform }}-yarn-
2020-09-27 18:45:54 +00:00
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
2020-10-02 01:22:35 +00:00
desktop/src-tauri/target
key: ${{ matrix.platform }}-cargo-v2-${{ hashFiles('**/Cargo.lock') }}
2020-09-27 18:45:54 +00:00
restore-keys: |
${{ matrix.platform }}-cargo-v2-
2020-09-27 18:45:54 +00:00
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 12
- name: install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install tauri bundler
if: runner.os != 'Windows'
run: cargo install tauri-bundler || [ $? -eq 101 ]
- name: install tauri bundler
if: runner.os == 'Windows'
run: cargo install tauri-bundler; exit ($LASTEXITCODE -ne 101 -and $LASTEXITCODE -ne 0)
shell: powershell -command "& '{0}'"
- name: install webkit2gtk (ubuntu only)
2020-09-27 20:03:54 +00:00
if: matrix.platform == 'ubuntu-18.04'
2020-09-27 18:45:54 +00:00
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0 squashfs-tools
- name: install app dependencies
run: yarn
- uses: tauri-apps/tauri-action@v0
2020-09-27 21:12:08 +00:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
npmScript: "tauri:build"
2020-10-02 01:22:35 +00:00
projectPath: desktop/
2020-09-27 21:12:08 +00:00
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
- name: Upload Release
if: runner.os == 'Linux'
uses: actions/github-script@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const {repo: {owner, repo}, sha} = context;
console.log({owner, repo, sha});
2020-11-23 00:11:14 +00:00
const {name, version} = require(`${process.env.GITHUB_WORKSPACE}/desktop/package.json`);
2020-09-27 21:12:08 +00:00
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: "${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}",
name: `${name}_${version}_${arch}.AppImage`,
2020-10-02 01:22:35 +00:00
data: await fs.readFile(`${process.env.GITHUB_WORKSPACE}/desktop/src-tauri/target/release/bundle/appimage/n-link.AppImage`)
2020-09-27 21:12:08 +00:00
});