Skip to content

Commit 9317edf

Browse files
authored
ci: adopt shared release workflow (#192)
1 parent 81e83d3 commit 9317edf

1 file changed

Lines changed: 3 additions & 119 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -8,125 +8,9 @@ permissions: {}
88

99
jobs:
1010
release:
11-
if: >-
12-
github.event.pull_request.merged == true &&
13-
github.event.pull_request.head.repo.full_name == github.repository &&
14-
startsWith(github.event.pull_request.head.ref, 'release/')
15-
concurrency:
16-
group: npm-release
17-
queue: max
18-
runs-on: ubuntu-latest
19-
environment: release
2011
permissions:
2112
contents: write
2213
id-token: write
23-
steps:
24-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25-
with:
26-
ref: ${{ github.event.pull_request.merge_commit_sha }}
27-
fetch-depth: 0
28-
29-
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
30-
31-
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
32-
with:
33-
node-version-file: '.nvmrc'
34-
registry-url: 'https://registry.npmjs.org'
35-
36-
- run: pnpm install --frozen-lockfile
37-
38-
- name: Read release config
39-
id: release_config
40-
shell: bash
41-
run: |
42-
node --no-warnings --input-type=module -e '
43-
import { releaseConfig } from "./bump.config.ts";
44-
console.log(`branch=${releaseConfig.branch}`);
45-
console.log(`npm_tag=${releaseConfig.npmTag}`);
46-
' >> "$GITHUB_OUTPUT"
47-
48-
- name: Determine release
49-
id: release
50-
shell: bash
51-
env:
52-
CONFIGURED_RELEASE_BRANCH: ${{ steps.release_config.outputs.branch }}
53-
RELEASE_BRANCH: ${{ github.event.pull_request.base.ref }}
54-
RELEASE_PR_BRANCH: ${{ github.event.pull_request.head.ref }}
55-
STABLE_NPM_TAG: ${{ steps.release_config.outputs.npm_tag }}
56-
run: |
57-
PACKAGE_VERSION=$(node -p "require('./packages/better-call/package.json').version")
58-
TAG="v$PACKAGE_VERSION"
59-
60-
if [[ "$RELEASE_BRANCH" != "$CONFIGURED_RELEASE_BRANCH" ]]; then
61-
echo "::error::Release branch $RELEASE_BRANCH does not match configured branch $CONFIGURED_RELEASE_BRANCH."
62-
exit 1
63-
fi
64-
65-
if [[ "$RELEASE_PR_BRANCH" != "release/$TAG" ]]; then
66-
echo "::error::Release branch $RELEASE_PR_BRANCH does not match package version $PACKAGE_VERSION."
67-
exit 1
68-
fi
69-
70-
if [[ "$PACKAGE_VERSION" =~ -(next|canary|beta|rc) ]]; then
71-
NPM_TAG=${BASH_REMATCH[1]}
72-
else
73-
if [[ ! "$PACKAGE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
74-
echo "::error::Unsupported release version: $PACKAGE_VERSION"
75-
exit 1
76-
fi
77-
78-
NPM_TAG="$STABLE_NPM_TAG"
79-
fi
80-
81-
echo "version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT"
82-
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
83-
echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT"
84-
echo "Releasing $TAG from $RELEASE_BRANCH with npm tag $NPM_TAG"
85-
86-
- name: Build
87-
run: pnpm build
88-
89-
- name: Create tag
90-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
91-
env:
92-
RELEASE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
93-
RELEASE_TAG: ${{ steps.release.outputs.tag }}
94-
with:
95-
script: |
96-
const ref = `tags/${process.env.RELEASE_TAG}`;
97-
const sha = process.env.RELEASE_SHA;
98-
99-
try {
100-
const { data } = await github.rest.git.getRef({
101-
owner: context.repo.owner,
102-
repo: context.repo.repo,
103-
ref,
104-
});
105-
106-
if (data.object.sha !== sha) {
107-
core.setFailed(`${process.env.RELEASE_TAG} already points to ${data.object.sha}.`);
108-
return;
109-
}
110-
111-
core.info(`${process.env.RELEASE_TAG} already points to ${sha}.`);
112-
} catch (error) {
113-
if (error.status !== 404) throw error;
114-
115-
await github.rest.git.createRef({
116-
owner: context.repo.owner,
117-
repo: context.repo.repo,
118-
ref: `refs/${ref}`,
119-
sha,
120-
});
121-
}
122-
123-
- name: Create GitHub release
124-
env:
125-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126-
RELEASE_TAG: ${{ steps.release.outputs.tag }}
127-
run: |
128-
git fetch origin "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"
129-
npx changelogithub --to "$RELEASE_TAG"
130-
131-
- name: Publish to npm
132-
run: pnpm -r publish --provenance --access public --no-git-checks --tag ${{ steps.release.outputs.npm_tag }}
14+
uses: better-auth/shared-workflows/.github/workflows/release-bumpp-library.yml@b574d729adc6831942ea65d4bcf991f0af4f2705
15+
with:
16+
version-file: packages/better-call/package.json

0 commit comments

Comments
 (0)