Publish #189
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
name: Publish | |
permissions: write-all | |
on: | |
workflow_run: | |
workflows: | |
- Build & Test | |
types: | |
- completed | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
sha: | |
description: 'SHA to release from' | |
required: true | |
type: string | |
target: | |
description: 'Which targets to release' | |
required: true | |
default: 'all' | |
type: choice | |
options: | |
- all | |
- npm | |
- docker | |
- electron | |
concurrency: ${{ github.workflow }}-${{ github.event.workflow_run.head_sha || inputs.sha }} | |
env: | |
SHA: ${{ github.event.workflow_run.head_sha || inputs.sha }} | |
BUILD_CACHE_KEY: ${{ github.event.workflow_run.head_sha || inputs.sha }} | |
CACHED_BUILD_PATHS: | | |
${{ github.workspace }}/packages/*/dist | |
${{ github.workspace }}/packages/*/dist-bin | |
jobs: | |
npm: | |
name: NPM Package | |
runs-on: ubuntu-latest | |
if: >- | |
(github.event.workflow_run.conclusion == 'success' | |
&& | |
contains(github.event.workflow_run.head_commit.message, 'meta(changelog): Update package versions') | |
) || inputs.target == 'npm' || inputs.target == 'all' | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.SHA }} | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: 'package.json' | |
cache: 'pnpm' | |
- name: Setup NPM dependencies | |
run: pnpm install | |
- name: Restore build cache | |
uses: actions/cache/restore@v4 | |
with: | |
enableCrossOsArchive: true | |
fail-on-cache-miss: true | |
path: ${{ env.CACHED_BUILD_PATHS }} | |
key: ${{ env.BUILD_CACHE_KEY }} | |
- name: Publish to NPM | |
uses: changesets/action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
BUILD_PLATFORMS: 'linux-x64,linux-arm64,win-x64,darwin-x64,darwin-arm64' | |
with: | |
publish: pnpm changeset:publish | |
createGithubReleases: true | |
- name: Gets latest created release info | |
id: latest_release_info | |
uses: gregziegan/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file_glob: true | |
file: packages/spotlight/dist-bin/spotlight-* | |
tag: ${{ steps.latest_release_info.outputs.tag_name }} | |
make_latest: false | |
docker: | |
name: Docker Image | |
runs-on: ubuntu-latest | |
if: >- | |
(github.event.workflow_run.conclusion == 'success' | |
&& | |
contains(github.event.workflow_run.head_commit.message, 'meta(changelog): Update package versions') | |
) || inputs.target == 'docker' || inputs.target == 'all' | |
steps: | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/setup-buildx-action@v3 | |
- name: Push Docker Image as latest | |
run: >- | |
docker buildx imagetools create | |
--tag ghcr.io/getsentry/spotlight:latest | |
ghcr.io/getsentry/spotlight:$SHA | |
- name: Summarize | |
run: | | |
echo "**Tag:** ``ghcr.io/getsentry/spotlight:$SHA``" >> $GITHUB_STEP_SUMMARY | |
electron: | |
name: Electron Build | |
runs-on: macos-latest | |
if: >- | |
(github.event.workflow_run.conclusion == 'success' | |
&& | |
contains(github.event.workflow_run.head_commit.message, 'meta(changelog): Update package versions') | |
) || inputs.target == 'electron' || inputs.target == 'all' | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.SHA }} | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: 'package.json' | |
cache: 'pnpm' | |
- name: Setup dependencies | |
run: pnpm install | |
- name: Restore build cache | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
enableCrossOsArchive: true | |
path: ${{ env.CACHED_BUILD_PATHS }} | |
key: ${{ env.BUILD_CACHE_KEY }} | |
- name: Build | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: pnpm --filter '@spotlightjs/electron...' build | |
- name: Build Electron | |
env: | |
APPLEID: ${{ secrets.APPLEID }} | |
APPLEIDPASS: ${{ secrets.APPLEIDPASS }} | |
TEAMID: ${{ secrets.TEAMID }} | |
CERT_PASS: ${{ secrets.CERT_PASS }} | |
MAIN_VITE_SENTRY_ORG: ${{ secrets.MAIN_VITE_SENTRY_ORG }} | |
MAIN_VITE_SENTRY_PROJECT: ${{ secrets.MAIN_VITE_SENTRY_PROJECT }} | |
MAIN_VITE_SENTRY_AUTH_TOKEN: ${{ secrets.MAIN_VITE_SENTRY_AUTH_TOKEN }} | |
CSC_LINK: ${{ secrets.CSC_LINK }} | |
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} | |
run: cd packages/electron && pnpm build:mac | |
- name: Gets latest created release info | |
id: latest_release_info | |
uses: gregziegan/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: packages/electron/dist/*.zip | |
tag: ${{ steps.latest_release_info.outputs.tag_name }} | |
file_glob: true | |
make_latest: false |