ci(release): build CLI in foreign repo for both beta and main

This commit is contained in:
Nicolas Meienberger 2024-02-04 15:49:10 +01:00
parent 395cea1bd1
commit 6110c18de9
2 changed files with 68 additions and 59 deletions

View File

@ -97,48 +97,53 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: create-tag needs: create-tag
steps: steps:
- name: Checkout code - name: Dispatch an action and get the run ID
uses: actions/checkout@v4 uses: codex-/return-dispatch@v1
id: return_dispatch
- name: Install Node.js
uses: actions/setup-node@v4
with: with:
node-version: 20 token: ${{ secrets.PAT_CLI }}
ref: main
repo: cli
owner: runtipi
workflow: build.yml
workflow_inputs: '{ "version": "${{ needs.create-tag.outputs.tagname }}" }'
- uses: pnpm/action-setup@v2.4.0 - name: Await Run ID ${{ steps.return_dispatch.outputs.run_id }}
name: Install pnpm uses: Codex-/await-remote-run@v1.11.0
id: pnpm-install
with: with:
version: 8 token: ${{ secrets.PAT_CLI }}
run_install: false repo: cli
owner: runtipi
run_id: ${{ steps.return_dispatch.outputs.run_id }}
run_timeout_seconds: 300
poll_interval_ms: 5000
- name: Get pnpm store directory - name: Create bin folder
id: pnpm-cache run: mkdir -p bin
- name: Download CLI form release on runtipi/cli repo
run: | run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT REPO="runtipi/cli"
VERSION="${{ needs.create-tag.outputs.tagname }}"
- uses: actions/cache@v4 ASSETS_URL=$(curl -s \
name: Setup pnpm cache -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
with: -H "Accept: application/vnd.github.v3+json" \
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} "https://api.github.com/repos/$REPO/releases/tags/$VERSION" \
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | jq -r '.assets[] | select(.name | test("runtipi-cli.+")) | .browser_download_url')
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies echo "Assets URL: $ASSETS_URL"
run: pnpm install
- name: Set version for url in $ASSETS_URL; do
run: pnpm -r --filter cli set-version ${{ needs.create-tag.outputs.tagname }} echo "Downloading from $url"
curl -L -o "bin/${url##*/}" -H "Accept: application/octet-stream" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$url"
- name: Build CLI done
run: pnpm -r --filter cli package
- name: Upload CLI - name: Upload CLI
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: cli name: cli
path: packages/cli/dist path: bin
publish-release: publish-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -92,51 +92,55 @@ jobs:
build-cli: build-cli:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10
needs: create-tag needs: create-tag
steps: steps:
- name: Checkout code - name: Dispatch an action and get the run ID
uses: actions/checkout@v4 uses: codex-/return-dispatch@v1
id: return_dispatch
- name: Install Node.js
uses: actions/setup-node@v4
with: with:
node-version: 20 token: ${{ secrets.PAT_CLI }}
ref: main
repo: cli
owner: runtipi
workflow: build.yml
workflow_inputs: '{ "version": "${{ needs.create-tag.outputs.tagname }}" }'
- uses: pnpm/action-setup@v2.4.0 - name: Await Run ID ${{ steps.return_dispatch.outputs.run_id }}
name: Install pnpm uses: Codex-/await-remote-run@v1.11.0
id: pnpm-install
with: with:
version: 8 token: ${{ secrets.PAT_CLI }}
run_install: false repo: cli
owner: runtipi
run_id: ${{ steps.return_dispatch.outputs.run_id }}
run_timeout_seconds: 300
poll_interval_ms: 5000
- name: Get pnpm store directory - name: Create bin folder
id: pnpm-cache run: mkdir -p bin
- name: Download CLI form release on runtipi/cli repo
run: | run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT REPO="runtipi/cli"
VERSION="${{ needs.create-tag.outputs.tagname }}"
- uses: actions/cache@v4 ASSETS_URL=$(curl -s \
name: Setup pnpm cache -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
with: -H "Accept: application/vnd.github.v3+json" \
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} "https://api.github.com/repos/$REPO/releases/tags/$VERSION" \
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | jq -r '.assets[] | select(.name | test("runtipi-cli.+")) | .browser_download_url')
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies echo "Assets URL: $ASSETS_URL"
run: pnpm install
- name: Set version for url in $ASSETS_URL; do
run: pnpm -r --filter cli set-version ${{ needs.create-tag.outputs.tagname }} echo "Downloading from $url"
curl -L -o "bin/${url##*/}" -H "Accept: application/octet-stream" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$url"
- name: Build CLI done
run: pnpm -r --filter cli package
- name: Upload CLI - name: Upload CLI
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: cli name: cli
path: packages/cli/dist path: bin
publish-release: publish-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest