-
Notifications
You must be signed in to change notification settings - Fork 1
85 lines (73 loc) · 2.88 KB
/
release.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
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
name: Release to npm
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: yarn install
- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
gpg-connect-agent reloadagent /bye
- name: Configure Git to use GPG
run: |
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep 'sec' | awk '{print $2}' | cut -d'/' -f2)
echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
git config --global user.signingkey $GPG_KEY_ID
git config --global commit.gpgsign true
git config --global gpg.program gpg
- name: Bump version
id: bump_version
run: |
NEW_VERSION=$(yarn version --patch --no-git-tag-version | grep 'New version' | awk '{print $NF}')
echo "::set-output name=new_version::$NEW_VERSION"
- name: Commit version bump
env:
GPG_TTY: ${{ env.GPG_TTY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git checkout -b release-branch
git add package.json
echo "$PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback --sign
git commit -S -m "chore(release): ${{ steps.bump_version.outputs.new_version }}"
git pull origin main --rebase
git push origin release-branch
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore(release): ${{ steps.bump_version.outputs.new_version }}'
base: main
branch: release-branch
title: 'Release ${{ steps.bump_version.outputs.new_version }}'
body: 'Automated release of version ${{ steps.bump_version.outputs.new_version }}'
- name: Build the project
if: github.event_name == 'pull_request'
run: yarn build
- name: Publish to npm
if: github.event_name == 'pull_request' && github.event.pull_request.merged
run: yarn publish --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}}