diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 44c04ef..9aad0c8 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -17,6 +17,8 @@ jobs: - name: Check last PR labels id: check_labels + env: + GH_TOKEN: ${{ github.token }} run: | LAST_PR_NUMBER=$(gh pr list --state merged --json number --jq '.[0].number') LABELS=$(gh pr view "$LAST_PR_NUMBER" --json labels --jq '.labels[].name') diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml deleted file mode 100644 index 8109daf..0000000 --- a/.github/workflows/prepare-release.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Package version bump -on: - pull_request_review: - types: [submitted] - pull_request: - paths: - - '.github/workflows/prepare-release.yml' - -jobs: - bump-version: - runs-on: ubuntu-latest - if: github.event.review.state == 'approved' - permissions: - contents: write # Highly security sensitive. Do NOT add third party actions in this job - pull-requests: read - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref_name }} - fetch-depth: 0 # https://yarnpkg.com/features/release-workflow#caveat - - - name: Show current branch - run: | - echo "Current branch: $(git branch --show-current)" - echo "Current commit: $(git rev-parse HEAD)" - git log --oneline -5 - - - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af #@v4 - with: - node-version: '20' - - - name: Check PR version labels - id: bump - run: | - # Check for version type labels - if ${{ contains(github.event.pull_request.labels.*.name, 'major') }}; then - echo "type=major" >> $GITHUB_OUTPUT - elif ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}; then - echo "type=minor" >> $GITHUB_OUTPUT - elif ${{ contains(github.event.pull_request.labels.*.name, 'patch') }}; then - echo "type=patch" >> $GITHUB_OUTPUT - else - echo "type=no-release" >> $GITHUB_OUTPUT - fi - - # Check for alpha label - if ${{ contains(github.event.pull_request.labels.*.name, 'alpha') }}; then - echo "alpha=true" >> $GITHUB_OUTPUT - echo "type=prerelease" >> $GITHUB_OUTPUT - else - echo "alpha=false" >> $GITHUB_OUTPUT - fi - - - name: Exit if no version bump - id: cancel - if: steps.bump.outputs.type == 'no-release' - run: | - echo "::warning::No version bump required. Skipping release steps." - - - name: Toggle Alpha - if: steps.bump.outputs.type != 'no-release' - run: | - if [ "${{ steps.bump.outputs.alpha }}" == "true" ]; then - ./.github/ci-scripts/toggle-alpha.sh yes - else - ./.github/ci-scripts/toggle-alpha.sh #remove alpha if present - fi - - - name: Bump version - if: steps.bump.outputs.type != 'no-release' - run: npm version ${{ steps.bump.outputs.type }} - - - name: Push changes - if: steps.bump.outputs.type != 'no-release' - run: | - VERSION=$(node -p "require('./package.json').version") - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - # Check if package.json has changes - if git diff --quiet package.json; then - echo "::notice::Version ${VERSION} is already pushed. No changes to commit." - else - git add package.json - git commit -am "chore: Bump version to ${VERSION}" - git push - fi - -