diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index bcd6402b..d4e1a349 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -6,15 +6,8 @@ on: jobs: checks: runs-on: ubuntu-latest - environment: ${{ github.base_ref == 'main' && 'production' || github.base_ref == 'v1' && 'production' || 'preview' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_PREID: ${{ vars.RELEASE_PREID }} - CUSTOM_BASE_REF: ${{ github.base_ref }} - CUSTOM_REF_NAME: ${{ github.ref_name }} - CUSTOM_HEAD_REF: ${{ github.head_ref }} - RELEASE_SPECIFIER: ${{ vars.RELEASE_SPECIFIER }} - RELEASE_TAG: ${{ vars.RELEASE_TAG }} steps: # Step 1: Check out the repository code @@ -63,7 +56,7 @@ jobs: # Step 9: Run the release in dry-run mode - name: Run Nx release version (dry-run) - run: pnpm release + run: pnpm exec nx release --first-release --skip-publish --dry-run # Step 10: Run publish in dry-run mode - name: Publish @@ -73,7 +66,7 @@ jobs: # Use npx instead of yarn because yarn automagically sets NPM_* environment variables # like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file # which is set up by `setup-node` action. - run: pnpx nx release publish --verbose --dry-run + run: pnpx nx release publish --first-release --verbose --dry-run # Step 11: Upload artifacts - name: Upload artifacts diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml deleted file mode 100644 index 6552383c..00000000 --- a/.github/workflows/release-preview.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Release - -on: - push: - branches: - - next - -jobs: - release: - runs-on: ubuntu-latest - environment: preview - permissions: - contents: write - id-token: write # needed for provenance data generation - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_PREID: ${{ vars.RELEASE_PREID }} - RELEASE_SPECIFIER: ${{ vars.RELEASE_SPECIFIER }} - RELEASE_TAG: ${{ vars.RELEASE_TAG }} - - steps: - # Step 1: Check out the repository code - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch the entire history to allow proper versioning - - # Step 2: Setup pnpm package manager - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9 - run_install: false - - # Step 3: Set up Node.js environment - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - registry-url: 'https://registry.npmjs.org' - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: '**/node_modules' - key: ${{ runner.OS }}-20.x-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.OS }}-20.x- - - # Step 5: Install dependencies - - name: Install dependencies - run: pnpm i --frozen-lockfile - - # Step 6: Set SHAs for nx workspace - - name: Set SHAs for Nx workspace - uses: nrwl/nx-set-shas@v4 - - # Step 7: Run lint and test for the affected changes - - name: Run Nx lint and test - run: pnpx nx affected -t lint test --exclude nextjs,vue3 - - # Step 8: Run the build for the affected changes - - name: Run build - run: pnpm build - - # Step 9: Set github authour - - name: Setup git user to "🤖 nabla bot" - run: git config user.email "-" && git config user.name "🤖 nabla bot" - - # Step 10: Run the release - - name: Run Nx release version - run: pnpm release -d false - - # Step 11: Run the build for the affected changes - - name: Run build - run: pnpm build - - # Step 12: Run publish - - name: Publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - NPM_CONFIG_PROVENANCE: true - # Use npx instead of yarn because yarn automagically sets NPM_* environment variables - # like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file - # which is set up by `setup-node` action. - run: npx nx release publish --verbose --tag $RELEASE_TAG - - # Step 13: Upload artifacts - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - path: './dist' diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml index f3dde29e..ec6fbeb8 100644 --- a/.github/workflows/release-production.yml +++ b/.github/workflows/release-production.yml @@ -9,15 +9,11 @@ on: jobs: release: runs-on: ubuntu-latest - environment: production permissions: contents: write id-token: write # needed for provenance data generation env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_PREID: ${{ vars.RELEASE_PREID }} - RELEASE_SPECIFIER: ${{ vars.RELEASE_SPECIFIER }} - RELEASE_TAG: ${{ vars.RELEASE_TAG }} steps: # Step 1: Check out the repository code @@ -71,7 +67,7 @@ jobs: # Step 10: Run the release - name: Run Nx release version - run: pnpm release -d false + run: pnpm exec nx release --first-release --skip-publish # Step 11: Run the build for the affected changes - name: Run build @@ -85,7 +81,7 @@ jobs: # Use npx instead of yarn because yarn automagically sets NPM_* environment variables # like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file # which is set up by `setup-node` action. - run: pnpx nx release publish --verbose + run: pnpx nx release publish --first-release --verbose --tag # Step 13: Upload artifacts - name: Upload artifacts diff --git a/nx.json b/nx.json index 7934a7b8..5c82b28a 100644 --- a/nx.json +++ b/nx.json @@ -80,21 +80,13 @@ "release": { "projects": ["packages/*"], "projectsRelationship": "independent", + "git": { + "commit": true + }, "version": { - "git": { - "commit": true - }, - "generatorOptions": { - "currentVersionResolver": "git-tag", - "specifierSource": "conventional-commits", - "fallbackCurrentVersionResolver": "disk", - "updateDependents": "auto" - } + "conventionalCommits": true }, "changelog": { - "git": { - "commit": true - }, "projectChangelogs": { "createRelease": "github" }, diff --git a/package.json b/package.json index e2c6454c..a80fd7c0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "build": "nx run-many --target=build --exclude nextjs,vue3 --parallel=6", "test": "nx run-many --target=test --exclude nextjs,vue3 --parallel=6", "lint": "nx run-many --target=lint --exclude nextjs,vue3 --parallel=6", - "release": "node tools/scripts/release.js", "prepare": "husky install" }, "private": true, diff --git a/tools/scripts/release.js b/tools/scripts/release.js deleted file mode 100644 index fe33679f..00000000 --- a/tools/scripts/release.js +++ /dev/null @@ -1,53 +0,0 @@ -const { - releaseChangelog, - releaseVersion, - releasePublish, -} = require('nx/release'); -const yargsBuilder = require('yargs'); -const { hideBin } = require('yargs/helpers'); - -const yargs = yargsBuilder(hideBin(process.argv)); - -const release = async () => { - const preid = process.env.RELEASE_PREID?.length - ? process.env.RELEASE_PREID - : undefined; - const specifier = process.env.RELEASE_SPECIFIER?.length - ? process.env.RELEASE_SPECIFIER - : undefined; - - const options = await yargs - .version(false) // don't use the default meaning of version in yargs - .option('dryRun', { - alias: 'd', - description: - 'Whether or not to perform a dry-run of the release process, defaults to true', - type: 'boolean', - default: true, - }) - .option('verbose', { - description: - 'Whether or not to enable verbose logging, defaults to false', - type: 'boolean', - default: false, - }) - .parseAsync(); - - const { workspaceVersion, projectsVersionData } = await releaseVersion({ - specifier, - dryRun: options.dryRun, - verbose: options.verbose, - preid, - }); - - await releaseChangelog({ - versionData: projectsVersionData, - version: workspaceVersion, - dryRun: options.dryRun, - verbose: options.verbose, - }); - - process.exit(); -}; - -release();