-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (39 loc) · 1.51 KB
/
publish-next.yml
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
name: Publish Next Tag Version
on:
push:
branches:
- main
jobs:
publish-next-tag-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Install release-please
run: npm install -g release-please
- name: Determine next version and update package.json
run: |
# Determine next version
OUTPUT=$(release-please release-pr --dry-run --token=${{ secrets.GITHUB_TOKEN }} --repo-url=${{ github.repository }} --target-branch=main)
echo "release-please output: $OUTPUT"
NEXT_VERSION=$(echo "$OUTPUT" | grep "chore(main): release atlas" | sed 's/.*atlas //')
echo "Next version: $NEXT_VERSION"
# Count existing pre-releases
NEXT_VERSION_COUNT=$(npm view . versions --json | jq "[.[] | select(startswith(\"$NEXT_VERSION-next.\"))] | length")
echo "Number of existing pre-releases: $NEXT_VERSION_COUNT"
# Create final version string
FINAL_VERSION="${NEXT_VERSION}-next.${NEXT_VERSION_COUNT}"
echo "Final version: $FINAL_VERSION"
# Update package.json
npm version $FINAL_VERSION --no-git-tag-version
npm publish --tag=next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}