Skip to content

Commit bd64801

Browse files
authored
Update release.yml
1 parent 3a2b8d7 commit bd64801

1 file changed

Lines changed: 18 additions & 125 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -5,135 +5,28 @@ on:
55
branches: [main]
66
types: [completed]
77

8-
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
11-
permissions: {}
8+
permissions:
9+
contents: write
10+
actions: write
11+
id-token: write
12+
pull-requests: write
13+
packages: write
1214

1315
jobs:
1416
release:
15-
name: Release
17+
if: github.event.workflow_run.conclusion == 'success'
1618
runs-on: ubuntu-latest
17-
timeout-minutes: 10
18-
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main'
19-
permissions:
20-
contents: write
21-
id-token: write
22-
pull-requests: write
23-
packages: write
2419
steps:
25-
- uses: actions/checkout@v6
20+
- uses: ProverCoderAI/action-release@v1.0.9
2621
with:
27-
fetch-depth: 0
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
npm_token: ${{ secrets.NPM_TOKEN }}
2824
ref: ${{ github.event.workflow_run.head_sha }}
29-
- name: Install dependencies
30-
uses: ./.github/actions/setup
31-
- name: Auto changeset (patch if no changeset exists)
32-
id: auto_changeset
33-
if: github.actor != 'github-actions[bot]'
34-
shell: bash
35-
run: |
36-
set -euo pipefail
37-
if ls .changeset/*.md >/dev/null 2>&1; then
38-
echo "has_changeset=true" >> "$GITHUB_OUTPUT"
39-
exit 0
40-
fi
41-
42-
CHANGESET_FILE=".changeset/auto-${{ github.sha }}.md"
43-
printf '%s\n' \
44-
'---' \
45-
'"@prover-coder-ai/context-doc": patch' \
46-
'---' \
47-
'' \
48-
'chore: automated version bump' \
49-
> "$CHANGESET_FILE"
50-
echo "has_changeset=true" >> "$GITHUB_OUTPUT"
51-
- name: Detect npm token
52-
id: npm_token
53-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]'
54-
shell: bash
55-
run: |
56-
set -euo pipefail
57-
if [ -n "${NPM_TOKEN:-}" ]; then
58-
echo "available=true" >> "$GITHUB_OUTPUT"
59-
else
60-
echo "available=false" >> "$GITHUB_OUTPUT"
61-
fi
62-
env:
63-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
64-
- name: Version packages
65-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]'
66-
run: pnpm changeset version
67-
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
- name: Read version
70-
id: release_version
71-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]'
72-
shell: bash
73-
run: |
74-
set -euo pipefail
75-
VERSION="$(node -p "require('./packages/app/package.json').version")"
76-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
77-
- name: Commit version changes
78-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]'
79-
shell: bash
80-
run: |
81-
set -euo pipefail
82-
if git diff --quiet; then
83-
exit 0
84-
fi
85-
git config user.name "github-actions[bot]"
86-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
87-
git add -A
88-
git commit -m "chore(release): version packages"
89-
BRANCH="${{ github.event.workflow_run.head_branch }}"
90-
if [ -z "${BRANCH}" ]; then
91-
BRANCH="main"
92-
fi
93-
git fetch origin "${BRANCH}"
94-
git rebase "origin/${BRANCH}"
95-
if ! git push origin "HEAD:${BRANCH}"; then
96-
git fetch origin "${BRANCH}"
97-
git rebase "origin/${BRANCH}"
98-
git push origin "HEAD:${BRANCH}"
99-
fi
100-
- name: Tag release
101-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]'
102-
shell: bash
103-
run: |
104-
set -euo pipefail
105-
VERSION="${{ steps.release_version.outputs.version }}"
106-
TAG="v${VERSION}"
107-
if git rev-parse "$TAG" >/dev/null 2>&1; then
108-
echo "Tag $TAG already exists"
109-
exit 0
110-
fi
111-
git tag -a "$TAG" -m "$TAG"
112-
git push origin "$TAG"
113-
- name: Configure npm auth
114-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]' && steps.npm_token.outputs.available == 'true'
115-
shell: bash
116-
run: |
117-
set -euo pipefail
118-
printf '%s\n' "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > "$HOME/.npmrc"
119-
env:
120-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
121-
- name: Publish
122-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]' && steps.npm_token.outputs.available == 'true'
123-
shell: bash
124-
run: |
125-
set -euo pipefail
126-
VERSION="$(node -p "require('./packages/app/package.json').version")"
127-
if npm view @prover-coder-ai/context-doc@"${VERSION}" version >/dev/null 2>&1; then
128-
echo "Version ${VERSION} already published; skipping npm publish."
129-
exit 0
130-
fi
131-
pnpm changeset-publish
132-
env:
133-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
134-
- name: Create GitHub Release
135-
if: steps.auto_changeset.outputs.has_changeset == 'true' && github.actor != 'github-actions[bot]'
136-
uses: softprops/action-gh-release@v2
137-
with:
138-
tag_name: v${{ steps.release_version.outputs.version }}
139-
generate_release_notes: true
25+
branch: ${{ github.event.workflow_run.head_branch }}
26+
package_json_path: packages/app/package.json
27+
pnpm_filter: ./packages/app
28+
bump_type: patch
29+
publish_npm: true
30+
publish_github_packages: true
31+
skip_if_unchanged: true
32+
cancel_on_no_changes: true

0 commit comments

Comments
 (0)