-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (112 loc) · 4.16 KB
/
deploy.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
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
112
113
114
115
116
117
118
name: Deploy Styleguide
concurrency: deploy
on:
push:
branches:
- main
paths:
- "src/**/*"
- "package.json"
- ".github/workflows/deploy.yml"
- "tsconfig.json"
workflow_dispatch:
inputs:
comment-id:
description: "The comment-id of the slash command"
required: true
event-number:
description: "The event-id of the slash command"
required: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ github.ref }}
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/[email protected]
with:
version: 9.0.6
run_install: true
- name: Metadata
id: metadata
run: echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Find Release Comment
uses: peter-evans/find-comment@v3
id: find_comment
if: ${{ github.ref != 'refs/heads/main' }}
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ github.event.inputs.event-number }}
comment-author: pythonitaliabot
body-includes: "Pre-release"
- name: Create or update comment
id: initial-comment
uses: peter-evans/create-or-update-comment@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
token: ${{ secrets.BOT_TOKEN }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.inputs.event-number }}
body: |
# Pre-release
:wave:
Releasing commit [${{ steps.metadata.outputs.commit }}] to NPM as pre-release! :package:
edit-mode: replace
- name: Update version
if: ${{ github.ref == 'refs/heads/main' }}
run: pnpm version patch --no-git-tag-version
- name: Update to pre-release version
if: ${{ github.ref != 'refs/heads/main' }}
run: |
pnpm version patch --no-git-tag-version
new_version=$(node -e "console.log(require('./package.json').version);")
pnpm version $new_version-rc${{ steps.metadata.outputs.commit }} --no-git-tag-version
- name: Build & Publish
id: release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm publish --tag ${{ fromJSON('["pr", "latest"]')[github.ref == 'refs/heads/main'] }} --no-git-checks
new_version=$(node -e "console.log(require('./package.json').version);")
echo "::set-output name=version::$new_version"
- name: Commit version
if: ${{ github.ref == 'refs/heads/main' }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
new_version=$(node -e "console.log(require('./package.json').version);")
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }}
git config user.name "Python Italia [bot]"
git config user.email "[email protected]"
git add package.json
git commit -m "🔨 Publish Styleguide v$new_version [skip ci]"
git push
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
if: ${{ github.ref != 'refs/heads/main' }}
with:
token: ${{ secrets.BOT_TOKEN }}
comment-id: ${{ steps.initial-comment.outputs.comment-id }}
issue-number: ${{ github.event.inputs.event-number }}
body: |
# Pre-release
:wave:
Pre-release **${{ steps.release.outputs.version }}** [${{ steps.metadata.outputs.commit }}] has been released on NPM! :rocket:
You can try it by doing:
```shell
pnpm add @python-italia/pycon-styleguide@${{ steps.release.outputs.version }}
```
edit-mode: replace