-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (85 loc) · 3.51 KB
/
Copy pathprerelease.yaml
File metadata and controls
105 lines (85 loc) · 3.51 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
name: Publish prerelease packages on NPM
permissions:
contents: read
packages: read
on:
release:
types: [created]
jobs:
validate-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate release type
run: |
# Check if this is a prerelease
if [[ "${{ github.event.release.prerelease }}" != "true" ]]; then
echo "❌ This workflow is for prereleases only. Please use the main release workflow for production releases."
exit 1
fi
# Check if the tag matches the version in lerna.json
RELEASE_VERSION="${{ github.event.release.tag_name }}"
LERNA_VERSION=$(node -p "require('./lerna.json').version")
if [[ "v$LERNA_VERSION" != "$RELEASE_VERSION" ]]; then
echo "❌ Release tag $RELEASE_VERSION doesn't match lerna.json version v$LERNA_VERSION"
exit 1
fi
echo "✅ Release validation passed"
build-and-publish:
runs-on: ubuntu-latest
needs: validate-release
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20.x'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build packages
run: |
export BUILD_MODE=release
yarn build
- name: Create packages
run: yarn lerna run pack --stream
- name: Publish core package
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN_FLAGGING_CORE }}" > ~/.npmrc
npm config set access public
cd packages/core
npm publish --tag alpha
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN_FLAGGING_CORE }}
- name: Wait for core package to be available
run: |
# Get the version from lerna.json
VERSION=$(node -p "require('./lerna.json').version")
PACKAGE_NAME="@datadog/flagging-core"
echo "Waiting for $PACKAGE_NAME@$VERSION to be available on npm..."
echo "This may take a few minutes due to npm registry propagation..."
# Wait up to 5 minutes (300 seconds) with 10-second intervals
for i in {1..30}; do
echo "Attempt $i/30: Checking if $PACKAGE_NAME@$VERSION is available..."
# Try to fetch the package info from npm
if npm view "$PACKAGE_NAME@$VERSION" --json > /dev/null 2>&1; then
echo "✅ $PACKAGE_NAME@$VERSION is now available on npm!"
echo "Package details:"
npm view "$PACKAGE_NAME@$VERSION" --json
break
fi
if [ $i -eq 30 ]; then
echo "❌ Timeout: $PACKAGE_NAME@$VERSION is still not available after 5 minutes"
echo "This might indicate an issue with the npm publish or registry propagation"
exit 1
fi
echo "Package not yet available, waiting 10 seconds..."
sleep 10
done
- name: Publish browser package
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISH_TOKEN }}" > ~/.npmrc
npm config set access public
cd packages/browser
npm publish --tag alpha
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}