-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (72 loc) · 2.7 KB
/
release.yml
File metadata and controls
89 lines (72 loc) · 2.7 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
name: Publish CLI Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{secrets.PAT}}
- name: Enable Corepack before setting up Node
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Authenticate to npm
run: |
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install dependencies
run: yarn install --immutable
- name: Build
run: yarn build
- name: Run tests
run: yarn test
- name: Version and Publish
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Configure both npm and GitHub Package registries
echo "registry=https://registry.npmjs.org/" > .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
echo "@niledatabase:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" >> .npmrc
# Run semantic-release
npx semantic-release
- name: Increment Alpha Version
if: success()
run: |
# Configure git
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
# Get the current version from main
MAIN_VERSION=$(node -p "require('./package.json').version")
# Checkout alpha branch
git fetch origin alpha
git checkout alpha
# Install dependencies to ensure package-lock.json is present
npm install
# Increment minor version and add alpha suffix
MAJOR_MINOR=$(echo $MAIN_VERSION | cut -d. -f1,2)
PATCH=$(echo $MAIN_VERSION | cut -d. -f3)
NEW_MINOR=$(($(echo $MAJOR_MINOR | cut -d. -f2) + 1))
NEW_VERSION="$(echo $MAJOR_MINOR | cut -d. -f1).$NEW_MINOR.0-alpha.1"
# Update package.json and package-lock.json with new version
npm version $NEW_VERSION --no-git-tag-version
# Commit and push changes
git add package.json package-lock.json
git commit -m "chore: bump version to $NEW_VERSION for future alpha releases [skip ci]"
git push origin alpha