Skip to content

ci: release workflow #106

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

Merged
merged 13 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions .github/actions/resolve-release-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Resolve version
description: Read "version" of "@tutorialkit/astro" to "steps.resolve-release-version.outputs.version"

outputs:
version:
description: 'Version of @tutorialkit/astro'
value: ${{ steps.resolve-release-version.outputs.version }}

runs:
using: composite

steps:
- name: Resolve release version
id: resolve-release-version
shell: bash
run: echo "version=$(jq -r .version ./packages/astro/package.json)" >> $GITHUB_OUTPUT
25 changes: 25 additions & 0 deletions .github/actions/setup-and-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Setup and build
description: Generic setup action for actions
inputs:
node-version:
required: false
description: Node version for setup-node
default: 20.x

runs:
using: composite

steps:
- name: Set node version to ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Install & Build
shell: bash
run: |
pnpm install
pnpm build
22 changes: 9 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Test
Expand All @@ -21,17 +23,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4

- uses: ./.github/actions/setup-and-build
with:
node-version: ${{ matrix.node-version }}
- name: Setup
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint
- name: Build
run: pnpm build

- name: Test
run: pnpm test

Expand All @@ -41,12 +40,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build

- uses: ./.github/actions/setup-and-build

- name: Build docs
run: |
pnpm run docs:build
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/integration-test-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Integration Tests CLI

on:
pull_request:
workflow_dispatch:

jobs:
cli-integration-test:
name: CLI Integration Tests
# Note: `prepare-release.yaml` sets this commit message
if: ${{ contains(github.event.pull_request.title, 'release tutorialkit CLI') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-and-build

- name: Update template's versions
working-directory: ./packages/cli
run: pnpm update-template

- name: Integration Tests
working-directory: ./integration
run: pnpm test
41 changes: 41 additions & 0 deletions .github/workflows/prepare-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Prepare release PR

on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish, e.g. 0.0.1'
required: true
default: '0.0.1'
type: string

jobs:
prepare_release:
name: Prepare release PR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-and-build

- name: Bump versions
run: >
pnpm --recursive
--filter "@tutorialkit/*"
exec pnpm version --no-git-tag-version --allow-same-version ${{ inputs.version }}

- name: Generage changelog
run: pnpm run changelog

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
# Note: `publish-release.yaml` checks explicitly for this commit message
commit-message: 'chore: release @tutorialkit packages, version: ${{ inputs.version }}'
title: 'chore: release @tutorialkit packages, version: ${{ inputs.version }}'
body: 'Bump packages to version ${{ inputs.version }} and generate changelogs'
reviewers: SamVerschueren,d3lm,Nemikolh,AriPerkkio
branch: chore/release-${{ inputs.version }}
108 changes: 108 additions & 0 deletions .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Publish release

on:
push:
branches:
- main

jobs:
publish_release:
name: Publish release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
Comment on lines +12 to +14
Copy link
Member Author

Choose a reason for hiding this comment

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

These are required for --provenance flag.

# Note: `prepare-release.yaml` sets this commit message
if: ${{ contains(github.event.head_commit.message, 'release @tutorialkit packages') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-and-build

# Sets steps.resolve-release-version.outputs.version
- uses: ./.github/actions/resolve-release-version
id: resolve-release-version

- name: Publish to npm
run: >
pnpm --recursive
--filter "@tutorialkit/*"
exec pnpm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Comment on lines +34 to +35
Copy link
Member Author

Choose a reason for hiding this comment

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

We'll need to manually add this secret to the project.

Copy link
Member

Choose a reason for hiding this comment

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

@d3lm I think if you can add @stackblitz-gitops to the packages, then we should be able to reuse the token of @stackblitz-gitops.

@apai4 Do you think that would be fine? Or should we have a different token?

Copy link
Contributor

Choose a reason for hiding this comment

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

I pinged Pai about this because I cannot add NPM access tokens since I don't have permissions to generate them.

Copy link
Member

Choose a reason for hiding this comment

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

I'll create a new token for stackblitz-devops on NPM for this repo and add it to secrets.NPM_TOKEN. stackblitz-devops will need write access to the NPM package.

Copy link
Member

Choose a reason for hiding this comment

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

The token has been created and added to the repo. Let me know if it works once stackblitz-gitops is granted access

Copy link
Member

Choose a reason for hiding this comment

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

@d3lm can you grant access to stackblitz-gitops on all the packages?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I can do that!

Copy link
Contributor

Choose a reason for hiding this comment

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

Invite is out. I think @apai4 needs to accept it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@d3lm do you have permissions to check if this is completed now? Publish step failed at https://github.com/stackblitz/tutorialkit/actions/runs/9791481416/job/27035364611


- name: Create and push git tag
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git tag v${{ steps.resolve-release-version.outputs.version }}
git push origin v${{ steps.resolve-release-version.outputs.version }}

prepare_cli_release:
name: Prepare release for CLI
needs: [publish_release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-and-build

# Sets steps.resolve-release-version.outputs.version
- uses: ./.github/actions/resolve-release-version
id: resolve-release-version

- name: Bump version
run: >
pnpm --recursive
--filter tutorialkit
--filter create-tutorial
exec npm version --no-git-tag-version --allow-same-version ${{ steps.resolve-release-version.outputs.version }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
# Note: `publish-release.yaml` checks explicitly for this commit message
commit-message: 'chore: release tutorialkit CLI, version: ${{ steps.resolve-release-version.outputs.version }}'
title: 'chore: release tutorialkit CLI, version: ${{ steps.resolve-release-version.outputs.version }}'
body: 'Bump tutorialkit CLI to version ${{ steps.resolve-release-version.outputs.version }}'
reviewers: SamVerschueren,d3lm,Nemikolh,AriPerkkio
branch: chore/release-cli-${{ steps.resolve-release-version.outputs.version }}

publish_release_CLI:
name: Publish release CLI
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
# Note: `prepare-release.yaml` sets this commit message
if: ${{ contains(github.event.head_commit.message, 'release tutorialkit CLI') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-and-build

- name: Update template's versions
working-directory: ./packages/cli
run: pnpm update-template

- name: Integration Tests
working-directory: ./integration
run: pnpm test

- name: Publish to npm
run: >
pnpm --recursive
--filter tutorialkit
--filter create-tutorial
exec pnpm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dist-ssr
*.sln
*.sw?
.pnpm-store
/tutorialkit/template
/packages/cli/template
tsconfig.tsbuildinfo
tsconfig.build.tsbuildinfo
.tmp
Expand Down
Loading
Loading