Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 12453d6

Browse files
committed
add release workflow
1 parent a54af08 commit 12453d6

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

.github/workflows/release.yaml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# For details see: https://superface.ai/blog/npm-publish-gh-actions-changelog
2+
name: Release package
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
release-type:
8+
type: choice
9+
required: true
10+
description:
11+
'The release type that will be passed to npm version command'
12+
options:
13+
[
14+
'patch',
15+
'minor',
16+
'major',
17+
'prepatch',
18+
'preminor',
19+
'premajor',
20+
'prerelease',
21+
]
22+
23+
jobs:
24+
release:
25+
name: Release
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Ensure running on main branch
30+
if: github.ref_name != github.event.repository.default_branch
31+
run: |
32+
echo "This workflow must not be triggered on a branch other than main"
33+
exit 1
34+
35+
# Checkout project repository
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
# Using deploy key to push changes to repository
40+
# See: https://stackoverflow.com/a/76135647
41+
ssh-key: ${{ secrets.DEPLOY_KEY }}
42+
43+
# Configure Git
44+
- name: Git configuration
45+
run: |
46+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
git config --global user.name "GitHub Actions"
48+
49+
# Setup Node.js environment
50+
- name: Setup Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 20
54+
registry-url: https://registry.npmjs.org/
55+
56+
# Bump package version
57+
# Use tag 'latest'
58+
- name: Bump release version
59+
if: startsWith(github.event.inputs.release-type, 'pre') != true
60+
run: |
61+
echo "TAG_NAME=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
62+
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
63+
env:
64+
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
65+
66+
# Bump package pre-release version
67+
# Use tag 'beta'
68+
- name: Bump pre-release version
69+
if: startsWith(github.event.inputs.release-type, 'pre')
70+
run: |
71+
echo "TAG_NAME=$(npm --no-git-tag-version --preid=beta version $RELEASE_TYPE)" >> $GITHUB_ENV
72+
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
73+
env:
74+
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
75+
76+
- name: Build and bump package version in the example
77+
run: |
78+
npm ci && cd example
79+
npm i @fishjam-dev/react-native-client && cd ..
80+
81+
# Commit changes
82+
- name: Commit changed files and create a new tag
83+
run: |
84+
git add package.json yarn.lock example/yarn.lock
85+
git commit -m "Release ${{ env.TAG_NAME }}"
86+
git tag ${{ env.TAG_NAME }}
87+
88+
# Publish version to public repository
89+
- name: Publish
90+
run: npm publish --verbose --access public --tag ${{ env.RELEASE_TAG }}
91+
env:
92+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
93+
94+
# Push repository changes
95+
- name: Push changes to repository
96+
run: |
97+
git push origin && git push --tags
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
101+
# Create GitHub release with autogenerated notes
102+
- name: Create GitHub release
103+
uses: softprops/action-gh-release@v2
104+
with:
105+
name: 'Release ${{ env.TAG_NAME }}'
106+
tag_name: ${{ env.TAG_NAME }}
107+
prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }}
108+
generate_release_notes: true
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)