Skip to content

Commit

Permalink
chore(cli): introduce fern CLI changelog (#4333)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Aug 19, 2024
1 parent d625288 commit 1485d04
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 46 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/create-cli-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release CLI

on:
push:
branches:
- main
paths:
- "packages/cli/cli/VERSION"

# Add this permissions block
permissions:
contents: write
pull-requests: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get version from file
id: get_version
run: echo "VERSION=$(cat packages/cli/cli/VERSION)" >> $GITHUB_OUTPUT

- name: Determine if prerelease
id: check_prerelease
run: |
if [[ "${{ steps.get_version.outputs.VERSION }}" == *"rc"* ]]; then
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
else
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: ${{ steps.check_prerelease.outputs.IS_PRERELEASE }}

- name: Display Release URL
run: echo "Release created at ${{ steps.create_release.outputs.html_url }}"

publish:
needs: create-release
uses: ./.github/workflows/publish-cli.yml
secrets: inherit
52 changes: 6 additions & 46 deletions .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: Publish CLI

on:
workflow_dispatch:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'

# Add this permissions block
permissions:
contents: write
pull-requests: write

jobs:
live-test:
environment: Fern Prod
Expand All @@ -32,50 +36,6 @@ jobs:
cli_path="$(pwd)/packages/cli/cli/dist/prod/bundle.cjs"
./scripts/live-test.sh "$cli_path" "$FERN_TOKEN"
publish-dev:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }}
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_PROJECT_API_KEY }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install
uses: ./.github/actions/install

- name: Print version
run: |
git_version="$(./scripts/git-version.sh)"
echo Publishing version: "${git_version}"
- name: Add version to dev package.json's
run: |
git_version="$(./scripts/git-version.sh)"
cd packages/cli/cli
mv package.json package.json.tmp
version_replace="s/0.0.0/${git_version}/"
cat package.json.tmp| sed "${version_replace}" > package.json
rm -rf package.json.tmp
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- name: Update pnpm lock with new versions
run: pnpm install

- name: Compile
run: pnpm --filter @fern-api/cli compile

- name: Publish fern-api-dev CLI
run: pnpm --filter @fern-api/cli publish:cli:dev --access restricted

publish-rc:
if: startsWith(github.ref, 'refs/tags/') && contains(github.ref, '-rc')
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/publish-dev-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish Dev CLI

on:
push:
branches:
- main

jobs:
publish-dev:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }}
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_PROJECT_API_KEY }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Install
uses: ./.github/actions/install

- name: Print version
run: |
git_version="$(./scripts/git-version.sh)"
echo Publishing version: "${git_version}"
- name: Add version to dev package.json's
run: |
git_version="$(./scripts/git-version.sh)"
cd packages/cli/cli
mv package.json package.json.tmp
version_replace="s/0.0.0/${git_version}/"
cat package.json.tmp| sed "${version_replace}" > package.json
rm -rf package.json.tmp
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- name: Update pnpm lock with new versions
run: pnpm install

- name: Compile
run: pnpm --filter @fern-api/cli compile

- name: Publish fern-api-dev CLI
run: pnpm --filter @fern-api/cli publish:cli:dev --access restricted
10 changes: 10 additions & 0 deletions packages/cli/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.39.7] - 2024-08-18

- Chore: Intialize this changelog
1 change: 1 addition & 0 deletions packages/cli/cli/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.39.8-rc1

0 comments on commit 1485d04

Please sign in to comment.