Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use two stage release process, plus diamond workflow for cross-compiling #2051

Merged
merged 7 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 118 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,113 @@
name: Release
name: Release From Branch

env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

on:
workflow_dispatch:
inputs:
increment:
description: "SemVer Increment"
required: true
default: "prerelease"
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
release_branch:
description: "Staging branch to run release from"

jobs:
build:
runs-on: macos-latest
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.TURBOBOT }}
ref: ${{ inputs.release_branch }}
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Test
run: pnpm -- turbo run test --filter=cli --color

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
darwin:
gsoltis marked this conversation as resolved.
Show resolved Hide resolved
name: "Build Darwin Binares"
needs: [smoke-test]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.release_branch }}
- run: git fetch origin --tags
- uses: ./.github/actions/setup-node
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
enable-corepack: false
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
install-only: true
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Build Artifacts
run: cd cli && make publish-turbo-darwin
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: turbo-artifacts-darwin
path: cli/dist-darwin

# Optional: working directory, useful for monorepos
working-directory: cli
# compiles linux and windows in a container
cross:
name: "Build Linux and Windows Binaries"
needs: [smoke-test]
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/vercel/turbo-cross:v1.18.5
steps:
- uses: actions/checkout@v3
with:
ref: "${{ inputs.release_branch }}"
- run: git fetch origin --tags
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
install-only: true
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Build Artifacts
run: cd cli && make publish-turbo-cross
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
gsoltis marked this conversation as resolved.
Show resolved Hide resolved
with:
name: turbo-artifacts-cross
path: cli/dist-cross

# `golangci-lint-action` does not have an "install only" option.
# We ignore the output of this run, instead using it just to install the binary.
args: --issues-exit-code=0
final-publish:
needs: [cross, darwin]
gsoltis marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "${{ inputs.release_branch }}"
- run: git fetch origin --tags
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- uses: ./.github/actions/setup-go
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Configure git
run: |
Expand All @@ -60,12 +123,38 @@ jobs:
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Version
run: |
./scripts/version.js ${{ inputs.increment }}
cat version.txt
# Download the prebuilt binaries for each platform,
# combine them into a single dist-combined folder,
# then delegate to goreleaser / Makefile for deploy.
# Finally, set up a PR for the branch we released off of
- name: Download Cross-compiled Artifacts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to include some code comments in this workflow about why we're doing this. You've explained it a couple times already and I'm still hazy, tbh 😓

uses: actions/download-artifact@v3
with:
name: turbo-artifacts-cross
path: cli/dist-cross

- name: Download Darwin Artifacts
uses: actions/download-artifact@v3
with:
name: turbo-artifacts-darwin
path: cli/dist-darwin

- name: Combine Artifacts
run: cd cli && mkdir -p dist-combined && cp -a dist-cross/. dist-combined/ && cp -a dist-darwin/. dist-combined/
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- name: Release
run: cd cli && make publish
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

- uses: repo-sync/pull-request@v2
with:
source_branch: ${{ inputs.release_branch }}
destination_branch: main
pr_title: Merge release branch ${{ inputs.release_branch }}
pr_body: ":crown: Merge release branch back to main"
pr_reviewer: ${{ github.actor }},gsoltis
pr_allow_empty: true
github_token: ${{ secrets.TURBOBOT }}
43 changes: 43 additions & 0 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Create Release Branch

# TODO: Once we have confidence with the release process, add an
# input to allow automatically kicking off the downstream release.
on:
workflow_dispatch:
inputs:
increment:
description: "SemVer Increment (prerelease = bump canary)"
required: true
default: "prerelease"
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major

jobs:
stage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.TURBOBOT }}
- uses: ./.github/actions/setup-node
with:
enable-corepack: false
- name: Configure git
run: |
git config --global user.name 'Turbobot'
git config --global user.email 'turbobot@vercel.com'
- name: Version
run: |
./scripts/version.js ${{ inputs.increment }}
cat version.txt
- name: Stage Commit
run: cd cli && make stage-release && echo "STAGE_BRANCH=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Show Stage Commit
run: echo "${{ env.STAGE_BRANCH }}"
1 change: 1 addition & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/demo/
/dist/
/dist-*

# Built binaries.
/turbo
Expand Down
93 changes: 0 additions & 93 deletions cli/.goreleaser.yaml

This file was deleted.

Loading