This repository was archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
111 lines (98 loc) · 3.51 KB
/
release.yaml
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
# For details see: https://superface.ai/blog/npm-publish-gh-actions-changelog
name: Release package
on:
workflow_dispatch:
inputs:
release-type:
type: choice
required: true
description:
'The release type that will be passed to npm version command'
options:
[
'patch',
'minor',
'major',
'prepatch',
'preminor',
'premajor',
'prerelease',
]
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Ensure running on main branch
if: github.ref_name != github.event.repository.default_branch
run: |
echo "This workflow must not be triggered on a branch other than main"
exit 1
# Checkout project repository
- name: Checkout
uses: actions/checkout@v4
with:
# Using deploy key to push changes to repository
# See: https://stackoverflow.com/a/76135647
ssh-key: ${{ secrets.DEPLOY_KEY }}
# Configure Git
- name: Git configuration
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
# Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
registry-url: https://registry.npmjs.org/
# Bump package version
# Use tag 'latest'
- name: Bump release version
if: startsWith(github.event.inputs.release-type, 'pre') != true
run: |
echo "TAG_NAME=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
# Bump package pre-release version
# Use tag 'beta'
- name: Bump pre-release version
if: startsWith(github.event.inputs.release-type, 'pre')
run: |
echo "TAG_NAME=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE)" >> $GITHUB_ENV
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
- name: Build and bump package version in the example
run: |
yarn install --frozen-lockfile && cd example
yarn upgrade @fishjam-dev/react-native-client && cd ..
# Commit changes
- name: Commit changed files and create a new tag
run: |
git add package.json yarn.lock example/yarn.lock
git commit -m "Release ${{ env.TAG_NAME }}"
git tag ${{ env.TAG_NAME }}
# Publish version to public repository
- name: Publish
run: npm publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Push repository changes
- name: Push changes to repository
run: |
git push origin && git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create GitHub release with autogenerated notes
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: 'Release ${{ env.TAG_NAME }}'
tag_name: ${{ env.TAG_NAME }}
prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}