-
Notifications
You must be signed in to change notification settings - Fork 2
93 lines (82 loc) · 2.99 KB
/
npm-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
86
87
88
89
90
91
92
93
name: Create npm and GitHub Release
on:
workflow_call:
inputs:
node-version:
required: true
type: string
require-build:
default: true
type: string
package-name:
required: true
type: string
release-directory:
default: './'
type: string
secrets:
github-token:
required: true
npm-token:
required: true
jobs:
release:
#if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
runs-on:
labels: ubuntu-latest
environment: release
steps:
# Checkout the code
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Get the version from the branch name
- id: get_version
uses: ./.github/actions/get-version
with:
version-file-path: "packages/${{ inputs.package-name }}/.version" # Path to version file
# Get the prerelease flag from the branch name
- id: get_prerelease
uses: ./.github/actions/get-prerelease
with:
version: ${{ steps.get-version.outputs.version }}
- name: Test GITHUB_TOKEN Permissions
run: |
curl -H "Authorization: token ${{ secrets.github-token }}" \
https://api.github.com/repos/${{ github.repository }}
# Get the release notes
# - id: get_release_notes
# uses: ./.github/actions/get-release-notes
# with:
# token: ${{ secrets.github-token }}
# version: ${{ steps.get_version.outputs.version }}
# repo_owner: ${{ github.repository_owner }}
# repo_name: ${{ github.event.repository.name }}
# Check if the tag already exists
- id: tag_exists
uses: ./.github/actions/tag-exists
with:
tag: ${{ steps.get_version.outputs.version }}
token: ${{ secrets.github-token }}
package: ${{ inputs.package-name }}
# If the tag already exists, exit with an error
- if: steps.tag_exists.outputs.exists == 'true'
run: exit 1
# Publish the release to our package manager
- uses: ./.github/actions/npm-publish
with:
node-version: ${{ inputs.node-version }}
require-build: ${{ inputs.require-build }}
version: ${{ steps.get_version.outputs.version }}
npm-token: ${{ secrets.npm-token }}
package: ${{ inputs.package-name }}
release-directory: ${{ inputs.release-directory }}
# Create a release for the tag
- uses: ./.github/actions/release-create
with:
token: ${{ secrets.github-token }}
name: ${{ steps.get_version.outputs.version }}
body: ${{ github.event.pull_request.body }}
tag: ${{ inputs.package-name }}-${{ steps.get_version.outputs.version }}
commit: ${{ github.sha }}
prerelease: ${{ steps.get_prerelease.outputs.prerelease }}