-
Notifications
You must be signed in to change notification settings - Fork 25
136 lines (119 loc) · 5.06 KB
/
Copy pathrelease.yml
File metadata and controls
136 lines (119 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Release
on:
push:
branches: [main, release-**]
workflow_dispatch:
jobs:
test:
uses: ./.github/workflows/test.yml
release:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.6
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: pnpm/action-setup@v4
with:
version: 11.1.3
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Publish snapshot
if: github.ref == 'refs/heads/main'
env:
# Run the prepublishOnly verify's turbo tasks one at a time. api-extractor
# intermittently fails ("Internal Error: Unable to determine module for
# dist/<entry>.d.ts") when several api-extractor/build tasks run in parallel.
TURBO_CONCURRENCY: "1"
run: |
# We're using 0.0.0 to avoid this version to be higher than released versions.
# To use it:
# "@restatedev/restate-sdk": "^0.0.0-SNAPSHOT"
VERSION="0.0.0-SNAPSHOT-$(date '+%Y%m%d%H%M%S')"
# Update all lib package versions using jq
for pkg in packages/libs/*/package.json; do
jq --arg ver "$VERSION" '.version = $ver' "$pkg" > "$pkg.tmp" && mv "$pkg.tmp" "$pkg"
done
# Update workspace protocol dependencies to use the snapshot version
pnpm install --no-frozen-lockfile
# We use dist-tag dev for the snapshot releases, see https://docs.npmjs.com/cli/v9/commands/npm-dist-tag for more info
# A snapshot MUST not be published with latest tag (omitting --tag defaults to latest) to avoid users to install snapshot releases
# when using pnpm install
pnpm --filter "./packages/libs/**" publish --tag dev --access public --no-git-checks --provenance
git checkout .
- name: Check for new version
id: check
run: |
git fetch --tags
for package in packages/libs/*/package.json; do
if [ -f "$package" ]; then
NAME=$(jq -r '.name' "$package")
VERSION=$(jq -r '.version' "$package")
PRIVATE=$(jq -r '.private // false' "$package")
if [ "$PRIVATE" = "false" ]; then
if ! git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "New version detected: $NAME@$VERSION"
echo "create_release=true" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Pre-release versions (e.g. 1.2.3-rc.1, 1.2.3-alpha.0) MUST NOT be published
# with the latest npm dist-tag (omitting --tag defaults to latest), otherwise
# users would get the pre-release on a plain install.
# We use the pre-release identifier (rc, alpha, beta, ...) as the dist-tag.
if [[ "$VERSION" == *-* ]]; then
PRERELEASE_ID="${VERSION#*-}"
PRERELEASE_ID="${PRERELEASE_ID%%.*}"
echo "Pre-release detected, using npm dist-tag: $PRERELEASE_ID"
echo "prerelease=true" >> "$GITHUB_OUTPUT"
echo "npm_tag=$PRERELEASE_ID" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
echo "npm_tag=latest" >> "$GITHUB_OUTPUT"
fi
break
fi
fi
fi
done
- name: Create and Push Tag
if: steps.check.outputs.create_release == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.check.outputs.version }}"
git push origin "v${{ steps.check.outputs.version }}"
- name: Create Release
if: steps.check.outputs.create_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXTRA_FLAGS=""
if [ "${{ steps.check.outputs.prerelease }}" = "true" ]; then
EXTRA_FLAGS="--prerelease"
fi
gh release create "v${{ steps.check.outputs.version }}" \
--title "Release v${{ steps.check.outputs.version }}" \
--generate-notes \
$EXTRA_FLAGS
- name: Publish release to npm
if: steps.check.outputs.create_release == 'true'
env:
TURBO_CONCURRENCY: "1" # serialize the prepublishOnly verify (see "Publish snapshot")
run: pnpm -r --filter='./packages/libs/**' publish --tag "${{ steps.check.outputs.npm_tag }}" --access public --no-git-checks --provenance