-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.71 KB
/
release.yml
File metadata and controls
56 lines (47 loc) · 1.71 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
name: Release
on:
push:
branches:
- main
jobs:
release:
# Prevents changesets action from creating a PR on forks
if: github.repository == 'zeroedin/z-changeset-practice'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm
- uses: google/wireit@setup-github-actions-caching/v2
- run: npm ci --prefer-offline
- run: npm run build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: npx changeset publish
commit: "chore: prepare release"
title: "chore: prepare release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create release branch
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
TAG_NAME="v$PACKAGE_VERSION"
RELEASE_BRANCH="release/${TAG_NAME}"
# Check if branch exists on GitHub
gh api repos/:owner/:repo/branches/$RELEASE_BRANCH >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Branch exists on GitHub, deleting..."
gh api -X DELETE repos/:owner/:repo/git/refs/heads/$RELEASE_BRANCH
fi
# Create and push new release branch
git checkout -b "$RELEASE_BRANCH"
git push origin "$RELEASE_BRANCH"
echo "Created release branch: $RELEASE_BRANCH"shell: /usr/bin/bash -e {0}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}