Better bun-release workflow

This commit is contained in:
Ashcon Partovi
2023-09-26 18:51:57 -07:00
parent 80195557c9
commit e127c520a9
4 changed files with 88 additions and 294 deletions

View File

@@ -1,166 +0,0 @@
name: bun-release-canary
concurrency: release-canary
on:
schedule:
- cron: "0 14 * * *" # every day at 6am PST
workflow_dispatch:
inputs:
use-docker:
description: Should Docker images be released?
type: boolean
default: false
use-npm:
description: Should npm packages be published?
type: boolean
default: false
use-s3:
description: Should binaries be uploaded to S3?
type: boolean
default: false
jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'oven-sh' }}
permissions:
contents: write
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-gpg
name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Sign Release
run: |
echo "$GPG_PASSPHRASE" | bun upload-assets -- "canary"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
npm:
name: Release to NPM
runs-on: ubuntu-latest
needs: sign
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-npm == 'true' }}
permissions:
contents: read
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-npm -- canary publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
docker:
name: Release to Dockerhub (${{ matrix.variant }})
runs-on: ubuntu-latest
needs: sign
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-docker == 'true' }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
variant:
- debian
- slim
- alpine
- distroless
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: qemu
name: Setup Docker QEMU
uses: docker/setup-qemu-action@v2
- id: buildx
name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- id: metadata
name: Setup Docker metadata
uses: docker/metadata-action@v4
with:
images: oven/bun
flavor: |
suffix=-${{ matrix.variant }}
tags: canary
- id: login
name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: push
name: Push to Docker
uses: docker/build-push-action@v3
with:
context: ./dockerhub/${{ matrix.variant }}
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
BUN_VERSION=canary
s3:
name: Upload to S3
runs-on: ubuntu-latest
needs: sign
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-s3 == 'true' }}
permissions:
contents: read
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-s3 -- canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_BUCKET: bun

View File

@@ -1,54 +1,66 @@
name: bun-release name: bun-release
concurrency: release concurrency: release
env:
BUN_VERSION: ${{ github.event.inputs.tag || github.event.release.tag_name || 'canary' }}
on: on:
release: release:
types: types:
- published - published
schedule:
- cron: "0 14 * * *" # every day at 6am PST
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag: tag:
type: string type: string
description: The tag to publish description: What is the release tag? (e.g. "1.0.2", "canary")
required: true required: true
use-docker:
description: Should Docker images be released?
type: boolean
default: false
use-npm:
description: Should npm packages be published?
type: boolean
default: false
use-homebrew:
description: Should binaries be released to Homebrew?
type: boolean
default: false
use-s3:
description: Should binaries be uploaded to S3?
type: boolean
default: false
use-types:
description: Should types be released to npm?
type: boolean
default: false
jobs: jobs:
sign: sign:
name: Sign Release name: Sign Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh' if: ${{ github.repository_owner == 'oven-sh' }}
permissions: permissions:
contents: write contents: write
defaults: defaults:
run: run:
working-directory: packages/bun-release working-directory: packages/bun-release
steps: steps:
- id: checkout - name: Checkout
name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- id: setup-env - name: Setup GPG
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-gpg
name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5 uses: crazy-max/ghaction-import-gpg@v5
with: with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }} passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-bun - name: Setup Bun
name: Setup Bun
uses: oven-sh/setup-bun@v1 uses: oven-sh/setup-bun@v1
with: with:
bun-version: canary bun-version: latest
- id: bun-install - name: Install Dependencies
name: Install Dependencies
run: bun install run: bun install
- id: bun-run - name: Sign Release
name: Sign Release
run: | run: |
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.TAG }}" echo "$GPG_PASSPHRASE" | bun upload-assets -- "${BUN_VERSION}"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
@@ -56,34 +68,23 @@ jobs:
name: Release to NPM name: Release to NPM
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: sign needs: sign
if: github.repository_owner == 'oven-sh' if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-npm == 'true' }}
permissions: permissions:
contents: read contents: read
defaults: defaults:
run: run:
working-directory: packages/bun-release working-directory: packages/bun-release
steps: steps:
- id: checkout - name: Checkout
name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- id: setup-env - name: Setup Bun
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1 uses: oven-sh/setup-bun@v1
with: with:
bun-version: canary bun-version: latest
- id: bun-install - name: Install Dependencies
name: Install Dependencies
run: bun install run: bun install
- id: bun-run - name: Release
name: Release run: bun upload-npm -- "${{ env.BUN_VERSION }}" publish
run: bun upload-npm -- "${{ env.TAG }}" publish
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -91,43 +92,28 @@ jobs:
name: Release types to NPM name: Release types to NPM
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: sign needs: sign
if: github.repository_owner == 'oven-sh' if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-types == 'true' }}
permissions: permissions:
contents: read contents: read
defaults: defaults:
run: run:
working-directory: packages/bun-types working-directory: packages/bun-types
steps: steps:
- id: checkout - name: Checkout
name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- id: setup-env - name: Setup Node.js
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-node
name: Setup Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: latest node-version: latest
- id: setup-bun - name: Setup Bun
name: Setup Bun
uses: oven-sh/setup-bun@v1 uses: oven-sh/setup-bun@v1
with: with:
bun-version: canary bun-version: latest
- id: bun-install - name: Install Dependencies
name: Install Dependencies
run: bun install run: bun install
- id: bun-run - name: Build
name: Build
run: bun run build run: bun run build
env: - name: Release
BUN_VERSION: ${{ env.TAG }}
- id: npm-publish
name: Release
uses: JS-DevTools/npm-publish@v1 uses: JS-DevTools/npm-publish@v1
with: with:
package: packages/bun-types/dist/package.json package: packages/bun-types/dist/package.json
@@ -136,30 +122,28 @@ jobs:
name: Release to Dockerhub (${{ matrix.variant }}) name: Release to Dockerhub (${{ matrix.variant }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: sign needs: sign
if: github.repository_owner == 'oven-sh' if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-docker == 'true' }}
permissions: permissions:
contents: read contents: read
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
variant: include:
- debian - variant: debian
- slim suffix: ''
- alpine - variant: debian
- distroless suffix: -debian
- variant: slim
suffix: -slim
dir: debian-slim
- variant: alpine
suffix: -alpine
- variant: distroless
suffix: -distroless
steps: steps:
- id: checkout - name: Checkout
name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- id: environment - name: Setup Docker emulator
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: qemu
name: Setup Docker QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v2
- id: buildx - id: buildx
name: Setup Docker buildx name: Setup Docker buildx
@@ -172,71 +156,58 @@ jobs:
with: with:
images: oven/bun images: oven/bun
flavor: | flavor: |
latest=${{ matrix.variant == 'debian' }} latest=${{ matrix.suffix == '' && github.event.release.tag_name == env.BUN_VERSION }}
suffix=-${{ matrix.variant }} suffix=${{ matrix.suffix }}
tags: | tags: |
type=match,pattern=(bun-v)?(\d+.\d+.\d+),group=2,value=${{ env.TAG }} type=match,pattern=(bun-v)?(canary|\d+.\d+.\d+),group=2,value=${{ env.BUN_VERSION }}
type=match,pattern=(bun-v)?(\d+.\d+),group=2,value=${{ env.TAG }} type=match,pattern=(bun-v)?(canary|\d+.\d+),group=2,value=${{ env.BUN_VERSION }}
type=match,pattern=(bun-v)?(\d+),group=2,value=${{ env.TAG }} type=match,pattern=(bun-v)?(canary|\d+),group=2,value=${{ env.BUN_VERSION }}
- id: login - name: Login to Docker
name: Login to Docker
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- id: push - name: Push to Docker
name: Push to Docker
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
with: with:
context: ./dockerhub/${{ matrix.variant }} context: ./dockerhub/${{ matrix.dir || matrix.variant }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }} builder: ${{ steps.buildx.outputs.name }}
push: true push: true
tags: ${{ steps.metadata.outputs.tags }} tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }} labels: ${{ steps.metadata.outputs.labels }}
build-args: | build-args: |
BUN_VERSION=${{ env.TAG }} BUN_VERSION=${{ env.BUN_VERSION }}
homebrew: homebrew:
name: Release to Homebrew name: Release to Homebrew
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: sign needs: sign
if: github.repository_owner == 'oven-sh'
permissions: permissions:
contents: read contents: read
if: ${{ github.event_name != 'schedule' || github.event.inputs.use-homebrew == 'true' }}
steps: steps:
- id: checkout - name: Checkout
name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
repository: oven-sh/homebrew-bun repository: oven-sh/homebrew-bun
token: ${{ secrets.ROBOBUN_TOKEN }} token: ${{ secrets.ROBOBUN_TOKEN }}
- id: setup-gpg - id: gpg
name: Setup GPG name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5 uses: crazy-max/ghaction-import-gpg@v5
with: with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }} passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-env - name: Setup Ruby
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-ruby
name: Setup Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: "2.6" ruby-version: "2.6"
- id: update-tap - name: Update Tap
name: Update Tap run: ruby scripts/release.rb "${{ env.BUN_VERSION }}"
run: ruby scripts/release.rb "${{ env.TAG }}" - name: Commit Tap
- id: commit-tap
name: Commit Tap
uses: stefanzweifel/git-auto-commit-action@v4 uses: stefanzweifel/git-auto-commit-action@v4
with: with:
commit_options: --gpg-sign=${{ steps.setup-gpg.outputs.keyid }} commit_options: --gpg-sign=${{ steps.gpg.outputs.keyid }}
commit_message: Release ${{ env.TAG }} commit_message: Release ${{ env.BUN_VERSION }}
commit_user_name: robobun commit_user_name: robobun
commit_user_email: robobun@oven.sh commit_user_email: robobun@oven.sh
commit_author: robobun <robobun@oven.sh> commit_author: robobun <robobun@oven.sh>
@@ -244,34 +215,23 @@ jobs:
name: Upload to S3 name: Upload to S3
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: sign needs: sign
if: github.repository_owner == 'oven-sh' if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-s3 == 'true' }}
permissions: permissions:
contents: read contents: read
defaults: defaults:
run: run:
working-directory: packages/bun-release working-directory: packages/bun-release
steps: steps:
- id: checkout - name: Checkout
name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- id: setup-env - name: Setup Bun
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1 uses: oven-sh/setup-bun@v1
with: with:
bun-version: canary bun-version: latest
- id: bun-install - name: Install Dependencies
name: Install Dependencies
run: bun install run: bun install
- id: bun-run - name: Release
name: Release run: bun upload-s3 -- "${{ env.BUN_VERSION }}"
run: bun upload-s3 -- "${{ env.TAG }}"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}