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

Refactor release workflow #106

Merged
merged 1 commit into from
Oct 18, 2024
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
28 changes: 5 additions & 23 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: cli
on:
workflow_call:
inputs:
release:
type: boolean
required: false
secrets:
NPM_TOKEN:
required: true
TURBO_TOKEN:
required: true
pull_request:
paths:
- .github/workflows/cli.yaml
Expand Down Expand Up @@ -48,22 +38,14 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Test / Coverage
working-directory: ./apps/cli
run: pnpm run test:coverage
- name: Build
run: pnpm build --filter @cartesi/cli

- name: Test
run: pnpm test --filter @cartesi/cli
tuler marked this conversation as resolved.
Show resolved Hide resolved

- name: "Report Coverage"
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./apps/cli
tuler marked this conversation as resolved.
Show resolved Hide resolved

- name: Build
run: pnpm build --filter @cartesi/cli

- name: Publish
if: ${{ inputs.release }}
working-directory: ./apps/cli
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/devnet.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: devnet
on:
workflow_call:
inputs:
release:
type: boolean
required: false
secrets:
NPM_TOKEN:
required: true
TURBO_TOKEN:
required: true
pull_request:
paths:
- .github/workflows/devnet.yaml
Expand Down Expand Up @@ -46,10 +36,3 @@ jobs:

- name: Build
run: pnpm build --filter @cartesi/devnet

- name: Publish
if: ${{ inputs.release }}
run: pnpm publish --access public
working-directory: packages/devnet
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 0 additions & 17 deletions .github/workflows/paymaster.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
name: paymaster
on:
workflow_call:
inputs:
release:
type: boolean
required: false
secrets:
NPM_TOKEN:
required: true
TURBO_TOKEN:
required: true
pull_request:
paths:
- .github/workflows/paymaster.yaml
Expand Down Expand Up @@ -48,10 +38,3 @@ jobs:

- name: Build
run: pnpm build --filter @cartesi/mock-verifying-paymaster

- name: Publish
if: ${{ inputs.release }}
working-directory: ./packages/mock-verifying-paymaster
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42 changes: 14 additions & 28 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,27 @@ jobs:
- name: Install Dependencies
run: pnpm install

- name: Create Release Pull Request
- name: Build
run: pnpm build

- name: Test
run: pnpm test
tuler marked this conversation as resolved.
Show resolved Hide resolved

- name: "Report Coverage"
if: always()
uses: davelosert/vitest-coverage-report-action@v2
with:
working-directory: ./apps/cli

- name: Create Release Pull Request or Publish to npm
id: changeset
uses: changesets/action@v1
with:
commit: "release: version packages"
publish: pnpm run publish-packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

packages_to_build:
name: Get released packages
Expand All @@ -66,30 +79,3 @@ jobs:
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/sdk') }}
uses: ./.github/workflows/sdk.yaml
secrets: inherit

build_devnet:
name: Build devnet
needs: [release, packages_to_build]
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/devnet') }}
uses: ./.github/workflows/devnet.yaml
secrets: inherit
with:
release: true

build_cli:
name: Build cli
needs: [release, packages_to_build]
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/cli') }}
uses: ./.github/workflows/cli.yaml
secrets: inherit
with:
release: true

build_paymaster:
name: Build paymaster
needs: [release, packages_to_build]
if: ${{ needs.release.outputs.published == 'true' && contains(fromJSON(needs.packages_to_build.outputs.packages), '@cartesi/mock-verifying-paymaster') }}
uses: ./.github/workflows/paymaster.yaml
secrets: inherit
with:
release: true
3 changes: 1 addition & 2 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
"postpack": "rimraf oclif.manifest.json",
"posttest": "pnpm lint",
"prepack": "pnpm build && oclif manifest",
"test": "vitest",
"test:coverage": "vitest --coverage.enabled true"
"test": "vitest"
},
"engines": {
"node": ">=18.0.0"
Expand Down
1 change: 1 addition & 0 deletions apps/cli/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
enabled: true,
tuler marked this conversation as resolved.
Show resolved Hide resolved
provider: "istanbul",
reporter: ["text", "json-summary", "json"],
reportOnFailure: true,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{cjs,css,json,md,mjs,ts,tsx}\"",
"publish-packages": "pnpm changeset tag && git push --follow-tags",
"preinstall": "npx only-allow pnpm"
"publish-packages": "pnpm changeset publish && git push --follow-tags",
"preinstall": "npx only-allow pnpm",
"test": "turbo test"
},
"devDependencies": {
"@cartesi/eslint-config": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"lint": {},
"start": {
"dependsOn": ["^build"]
},
"test": {
"outputs": ["coverage/**"],
"dependsOn": []
}
}
}
Loading