diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index c5b6887..f30f637 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -16,17 +16,8 @@ jobs: with: fetch-depth: 0 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - cache: "pnpm" - - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Setup + uses: ./.github/actions/setup - name: Validate commit message run: pnpm exec commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.sha }} --verbose diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index 722abe9..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Create release PR - -on: - workflow_dispatch: - inputs: - version: - required: true - type: choice - description: Which version should be published? - options: - - patch - - minor - - major - - prepatch - - preminor - - premajor - - prerelease - tag: - required: true - type: choice - description: Which npm tag should this be published to? - options: - - latest - - next - preid: - type: choice - description: Which prerelease identifier should be used? This is only needed when version is "prepatch", "preminor", "premajor", or "prerelease". - options: - - "" - - alpha - - beta - - rc - - next - -jobs: - create-release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Calculate new version - id: version - run: | - # Read current version from manifest - CURRENT_VERSION=$(jq -r '."."' .release-please-manifest.json) - echo "Current version: $CURRENT_VERSION" - - # Install semver for version calculation - npm install -g semver - - # Calculate new version based on input - NEW_VERSION=$(semver -i ${{ inputs.version }} $CURRENT_VERSION) - echo "New version: $NEW_VERSION" - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT - - - name: Create release commit - run: | - git config user.name "ambitiondev-release-bot[bot]" - git config user.email "ambitiondev-release-bot[bot]@users.noreply.github.com" - git commit --allow-empty -m "chore: release ${{ steps.version.outputs.new_version }}" -m "Release-As: ${{ steps.version.outputs.new_version }}" - git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d42c547..7db14ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,85 +1,48 @@ -name: Release +name: Create release on: - push: - branches: - - main + workflow_dispatch: + inputs: + version: + required: true + type: choice + description: Which version should be published? + options: + - patch + - minor + - major + - prepatch + - preminor + - premajor + - prerelease + tag: + required: true + type: choice + description: Which npm tag should this be published to? + options: + - latest + - next jobs: - # STAGE 1: Detect Release - detect: - name: Detect Release + create-release: runs-on: ubuntu-latest - outputs: - release_created: ${{ steps.release.outputs.release_created }} - tag_name: ${{ steps.release.outputs.tag_name }} - body: ${{ steps.release.outputs.body }} steps: - - name: Generate Token - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ secrets.BOT_APP_ID }} - private-key: ${{ secrets.BOT_PRIVATE_KEY }} - - name: Checkout uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - fetch-depth: 0 - - name: Release Please - id: release - uses: googleapis/release-please-action@v4 - with: - token: ${{ steps.app-token.outputs.token }} + - name: Configure Git Identity + run: | + git config user.name "ambitiondev-release-bot[bot]" + git config user.email "ambitiondev-release-bot[bot]@users.noreply.github.com" - # STAGE 2: Build & Publish - publish: - name: Build & Publish - needs: detect - if: ${{ needs.detect.outputs.release_created }} - runs-on: ubuntu-latest - environment: npm-publish - permissions: - id-token: write - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ needs.detect.outputs.tag_name }} + - name: Setup + uses: ./.github/actions/setup - - name: Build - uses: ./.github/actions/build + - name: Install changelogen + run: pnpm add -g changelogen - - name: Publish to NPM + - name: Create new version + id: version run: | pnpm config set //registry.npmjs.org/:_authToken "" - pnpm publish --no-git-checks --provenance --access public - - - name: Determine if Prerelease - id: prerelease - run: | - if [[ "${{ needs.detect.outputs.tag_name }}" =~ -.*$ ]]; then - echo "is_prerelease=true" >> $GITHUB_OUTPUT - else - echo "is_prerelease=false" >> $GITHUB_OUTPUT - fi - - - name: Create GitHub Release - shell: bash - run: | - echo "${{ needs.detect.outputs.body }}" > release_notes.md - - PRERELEASE_FLAG="" - if [ "${{ steps.prerelease.outputs.is_prerelease }}" = "true" ]; then - PRERELEASE_FLAG="--prerelease" - fi - - gh release create ${{ needs.detect.outputs.tag_name }} \ - --title "${{ needs.detect.outputs.tag_name }}" \ - --notes-file release_notes.md \ - $PRERELEASE_FLAG - env: - GH_TOKEN: ${{ github.token }} + pnpm dlx changelogen --bump --release --${{ github.event.inputs.version }} --publishTag ${{ github.event.inputs.tag }} --push --publish