Skip to content

Commit

Permalink
build: add structured release process
Browse files Browse the repository at this point in the history
  • Loading branch information
philostler committed Mar 21, 2024
1 parent 38e0aaf commit 93c808f
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 58 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build
on:
workflow_call:
inputs:
upload-artifact:
default: false
description: Whether to upload the build artifact
required: false
type: boolean
jobs:
www:
name: www
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/workflows/www/setup
- name: Build
# Linting has already been validated so skip to improve build speed
run: yarn build --no-lint
working-directory: packages/www
- name: Upload artifact
uses: actions/upload-artifact@v4
if: inputs.upload-artifact
with:
name: www
path: packages/www/out
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy
on:
workflow_dispatch:
inputs:
component:
description: Component
options:
- www
required: true
type: choice
version:
description: Version
required: true
type: string
permissions:
id-token: write
pages: write
jobs:
deploy:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: robinraju/release-downloader@v1.9
name: Download release
with:
extract: true
fileName: ${{ inputs.component }}-${{ inputs.version }}.zip
tag: ${{ inputs.component }}-${{ inputs.version }}
- name: List Files
run: ls -R
- name: Upload
uses: actions/upload-pages-artifact@v3
with:
path: ${{ inputs.component }}-${{ inputs.version }}
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
15 changes: 15 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Format
on:
workflow_call:
jobs:
www:
name: www
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/workflows/www/setup
- name: Check formatting
run: yarn format:check
working-directory: packages/www
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint
on:
workflow_call:
jobs:
www:
name: www
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/workflows/www/setup
- name: Check linting
run: yarn lint:check
working-directory: packages/www
57 changes: 0 additions & 57 deletions .github/workflows/main-push.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Pull Request
on:
pull_request:
branches:
- "!release-please*/*"
jobs:
format:
name: Format
uses: ./.github/workflows/format.yml
lint:
name: Lint
uses: ./.github/workflows/lint.yml
build:
name: Build
needs: [format, lint]
uses: ./.github/workflows/build.yml
47 changes: 47 additions & 0 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Push main
on:
push:
branches: main
permissions:
contents: write
pull-requests: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
tag_name: ${{ steps.release.outputs['packages/www--tag_name'] }}
version: ${{ steps.release.outputs['packages/www--major'] }}.${{ steps.release.outputs['packages/www--minor'] }}.${{ steps.release.outputs['packages/www--patch'] }}
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: release-please-manifest.json
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
format:
name: Format
needs: release
if: needs.release.outputs.releases_created == 'true'
uses: ./.github/workflows/format.yml
lint:
name: Lint
needs: release
if: needs.release.outputs.releases_created == 'true'
uses: ./.github/workflows/lint.yml
build:
name: Build
needs: [release, format, lint]
if: needs.release.outputs.releases_created == 'true'
uses: ./.github/workflows/build.yml
with:
upload-artifact: true
upload-to-release:
name: Upload to release
needs: [release, build]
if: needs.release.outputs.releases_created == 'true'
uses: ./.github/workflows/upload-to-release.yml
with:
tag_name: ${{ needs.release.outputs.tag_name }}
version: ${{ needs.release.outputs.version }}
30 changes: 30 additions & 0 deletions .github/workflows/upload-to-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Upload to Release
on:
workflow_call:
inputs:
tag_name:
description: Tag name to upload to
required: true
type: string
version:
description: Version number
required: true
type: string
jobs:
www:
name: www
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: www
path: www
- name: Archive
run: zip -r www-${{ inputs.version }}.zip www
- name: Upload to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ inputs.tag_name }} www-${{ inputs.version }}.zip
22 changes: 22 additions & 0 deletions .github/workflows/www/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Setup
runs:
using: composite
steps:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
cache: yarn
cache-dependency-path: packages/www/yarn.lock
node-version-file: packages/www/package.json
- name: Restore Next.js build cache
uses: actions/cache@v4
with:
path: packages/www/.next/cache
# Generate a new cache whenever packages or source files change
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
run: yarn install
shell: bash
working-directory: packages/www
2 changes: 2 additions & 0 deletions packages/www/.prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.next

CHANGELOG.md
2 changes: 1 addition & 1 deletion packages/www/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "www.philostler.com",
"name": "@philostler.com/www",
"version": "1.0.0",
"private": true,
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"include-v-in-tag": false,
"packages": {
"packages/www": {
"package-name": "www"
}
},
"pull-request-header": ":rocket: In the Next Release..."
}
3 changes: 3 additions & 0 deletions release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"packages/www": "1.0.0"
}

0 comments on commit 93c808f

Please sign in to comment.