Skip to content

Commit

Permalink
Automating release pipeline (#2)
Browse files Browse the repository at this point in the history
* feat: updated release workflow

feat: updated release workflows

* feat: added pull-request action

* chore: update readme

* chore: cleanup workflow

* chore: changeset
  • Loading branch information
alexlwn123 authored Sep 18, 2024
1 parent 3f88426 commit 012e4a1
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-pots-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fedimint/core-web': patch
---

Added workflows for pull request checks including calculating the compressed size of packages
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
name: Release
name: Changesets

on:
push:
branches:
- main
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml

release:
name: Release
changesets:
name: Publish Changesets
needs: verify
permissions:
contents: write
id-token: write
pull-requests: write
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand All @@ -30,7 +33,7 @@ jobs:
- name: Install dependencies
uses: ./.github/actions/install-deps

- name: Create Release Pull Request
- name: PR or Publish to NPM
uses: changesets/action@v1
with:
publish: pnpm release
Expand All @@ -40,6 +43,7 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish prerelease
# Only publish a prerelease if we didn't publish a release
if: steps.changesets.outputs.published != 'true'
continue-on-error: true
env:
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
name: Deploy Vite-Core Example to GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
paths: ['packages/core-web/**', 'examples/vite-core/**']
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
name: Deploy Vite-Core Example to GitHub Pages
environment:
name: '@fedimint/core-web + Vite Example'
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -38,11 +34,13 @@ jobs:

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: 'examples/vite-core/dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
31 changes: 31 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Pull Request
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml

size:
name: Size
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v4

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

- name: Report build size
uses: preactjs/compressed-size-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pattern: '{**/dist/**/*.{js,mjs,cjs},**/*.wasm}'
32 changes: 32 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Snapshot
on:
workflow_dispatch:

jobs:
snapshot:
name: Release snapshot version
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3

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

- name: Publish Snapshot
continue-on-error: true
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
snapshot=$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN"
git reset --hard origin/main
pnpm clean
pnpm changeset version --no-git-tag --snapshot $snapshot
pnpm changeset:prepublish
pnpm changeset publish --no-git-tag --snapshot $snapshot --tag $snapshot
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![License](https://img.shields.io/github/license/fedimint/fedimint-web-sdk)
![NPM Version](https://img.shields.io/npm/v/%40fedimint%2Fcore-web)
![NPM Version (latest)](https://img.shields.io/npm/v/%40fedimint%2Fcore-web)
![NPM Version (canary)](https://img.shields.io/npm/v/%40fedimint%2Fcore-web/canary)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/fedimint/fedimint-web-sdk/.github%2Fworkflows%2Fdeploy-preview.yml?label=example%20deployed%20to%20github%20pages&link=https%3A%2F%2Ffedimint.github.io%2Ffedimint-web-sdk%2F)
![Release Workflow](https://img.shields.io/github/actions/workflow/status/fedimint/fedimint-web-sdk/.github%2Fworkflows%2Frelease.yml?label=release%20workflow)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"release": "pnpm run build && pnpm changeset publish",
"reset": "pnpm clean && pnpm build && pnpm build:pages && pnpm preview",
"changeset": "changeset",
"changeset:prepublish": "pnpm run build",
"version": "changeset version",
"typecheck": "pnpm run --r --parallel typecheck",
"format": "prettier --write .",
Expand Down

0 comments on commit 012e4a1

Please sign in to comment.