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

feat: scaffold release workflows #2278

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 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
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ name: CI Checks
on:
pull_request:
branches:
- main
- master
push:
branches:
- main
- master

permissions:
Expand All @@ -26,23 +24,31 @@ jobs:
- 12
- 14
- 16
- 18
- 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install Dependencies
run: npm clean-install
run: npm ci --ignore-scripts

- name: Lint
run: npm run lint

- name: Integration Tests
run: npm run test:integration

- name: Test Coverage
run: npm run test:coverage

- name: Report test coverage to Coveralls.io
if: matrix.node == '16'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: TypeScript Test
run: npx --package typescript tsc --project test
91 changes: 91 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: "Create Release PR"

on:
workflow_dispatch:
inputs:
branch:
description: "What branch should the SDK be built from?"
required: true
default: "master"
type: string
versionType:
description: "What kind of version bump is this?"
required: true
type: choice
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
dryRun:
description: "Should publish be a dry run?"
required: false
default: false
type: boolean

jobs:
generate-sdk:
name: Generate SDK
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}

- name: Setup Node
uses: actions/setup-node@v3
env:
NODE_AUTH_TOKEN: ${{secrets.BOT_PAT}}
with:
node-version: 16
cache: 'npm'

- name: Install dependencies
run: npm ci --ignore-scripts

# Commit version if it's not a pre-release version
- name: Commit version bump
if: ${{ !startsWith(inputs.versionType, 'pre') }}
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
ACTOR: ${{ github.actor }}
run: |
ACTOR_INFO=$(gh api /users/$ACTOR)
ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id')
ACTOR_EMAIL="[email protected]"
ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name')

SHORT_SHA=$(echo ${{ github.sha }} | cut -c-7)
VERSION=$(npm version ${{ inputs.versionType }} ${{ startsWith(inputs.versionType, 'pre') && '--preid=ci-$SHORT_SHA' || '' }} --no-git-tag-version)
echo "VERSION=$VERSION" >> $GITHUB_ENV

git config --global user.name ''
git config --global user.email ''
git add
git commit -m "Bumping Package - $VERSION" \
-m "" \
-m "" \
-m "Co-authored-by: $ACTOR_NAME <$ACTOR_EMAIL>"

# If version bump is a pre-release just go ahead and publish (dry run or otherwise)
# Do we have any interest in tagging pre-release versions?
- name: Publish pre-release package ${{ inputs.dryRun && '(Dry Run)' || '' }}
if: ${{ startsWith(inputs.versionType, 'pre') }}
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: npm publish ${{ inputs.dryRun && '--dry-run' || '' }}

# If version bump is not a pre-release and not a dry run, create release PR for human review
- name: Open Release PR
if: ${{ !inputs.dryRun && !startsWith(inputs.versionType, 'pre') }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.BOT_PAT }}
delete-branch: true
branch: "release/${{ env.VERSION }}"
title: "Release: ${{ env.VERSION }}"
labels: "release, automated"
41 changes: 41 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Generate & Ship Release #ShipIt"

on:
push:
tags:
- release-**
jobs:
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Create release from tag
uses: ncipollo/[email protected]
with:
makeLatest: true
generateReleaseNotes: true

publish-sdk-version:
name: Publish Version
if: contains(github.ref, 'sdk')
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
env:
NODE_AUTH_TOKEN: ${{secrets.BOT_PAT}}
with:
node-version: 16
cache: 'npm'

- name: Prepare for publish
run: npm ci --ignore-scripts

- name: Publish package
run: npm publish
71 changes: 71 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: "Tag Release Commit"

on:
pull_request:
types:
- closed
branches:
- master

jobs:
was_merged:
name: Was PR Merged?
runs-on: ubuntu-latest
outputs:
result: ${{ steps.merge_check.outputs.result }}
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
steps:
- id: merge_check
run: echo "result=${{ github.event.pull_request.merged == true }}" >> $GITHUB_OUTPUT

is_release:
name: Is PR a release?
runs-on: ubuntu-latest
outputs:
result: ${{ steps.merge_check.outputs.result }}
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
steps:
- id: merge_check
run: echo "result=${{ contains( env.PR_BRANCH, 'release') }}" >> $GITHUB_OUTPUT

tag-merge-commit:
name: Tag release merge commit
needs:
- was_merged
- is_release
if: ${{ needs.was_merged.outputs.result == 'true' }} && ${{ needs.is_release.result == 'true' }}
env:
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
ACTOR_ID: ${{ github.event.pull_request.merged_by.id }}
MERGE_AT: ${{ github.event.pull_request.merged_at }}
MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }}
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_PAT }}

- name: Tag commit with version
env:
ACTOR: ${{ github.actor }}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
ACTOR_INFO=$(gh api /users/$ACTOR)
ACTOR_ID=$(echo $ACTOR_INFO | jq -r '.id')
ACTOR_EMAIL="[email protected]"
ACTOR_NAME=$(echo $ACTOR_INFO | jq -r '.name')
TAG_NAME=release-sdk-${PR_BRANCH##*/}

git config --global user.name ''
git config --global user.email ''

git tag -a $TAG_NAME \
-m "Automated Release $TAG_NAME" \
-m "" \
-m "" \
-m "Merged By: $ACTOR_NAME <$ACTOR_EMAIL>" \
-m "Merged At: $MERGED_AT" $MERGE_COMMIT_SHA
git push origin $TAG_NAME
2 changes: 2 additions & 0 deletions test/unit/formats/errors.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
- main
- main
maverick1872 marked this conversation as resolved.
Show resolved Hide resolved
* errors.test.js: E2E Integration tests of `new Error()` handling
*
* (C) 2010 Charlie Robbins
Expand Down