-
Notifications
You must be signed in to change notification settings - Fork 290
51 lines (49 loc) · 1.65 KB
/
tag.reusable.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
name: tag package
on:
workflow_call:
inputs:
path:
description: 'Path to the package.json file'
required: true
type: string
workspace:
description: 'Workspace name'
required: true
type: string
jobs:
check:
# TODO: Output `changed: true` only when version is higher than previous, not just changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check version change in push
id: relative
uses: EndBug/version-check@v2
with:
file-name: ${{ inputs.path }}
diff-search: true
# Only compare before and after if before exists, else check commits
file-url: ${{ github.event.before && '::before' }}
static-checking: ${{ github.event.before && 'localIsNew' }}
outputs:
changed: ${{ steps.relative.outputs.changed }}
version: ${{ steps.relative.outputs.version }}
tag:
runs-on: ubuntu-latest
needs:
- check
if: needs.check.outputs.changed == 'true'
steps:
- uses: actions/checkout@v3
- name: Prepare Yarn
uses: ./.github/actions/prepare/
- name: Tag on NPM
run: yarn npm tag add ${{ inputs.workspace }}@${{ needs.check.outputs.version }} latest
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
YARN_NPM_REGISTRY_SERVER: 'https://registry.npmjs.org'
- name: Tag on GitHub
run: yarn npm tag add ${{ inputs.workspace }}@${{ needs.check.outputs.version }} latest
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
YARN_NPM_REGISTRY_SERVER: 'https://npm.pkg.github.com'