-
Notifications
You must be signed in to change notification settings - Fork 14
/
action.yml
134 lines (126 loc) · 5.43 KB
/
action.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: 'Auto Publish'
description: 'Automatically publish to NPM and create Github release'
inputs:
github-token:
description: "Your Github token, it's already available to your Github action"
required: false
default: ${{ github.token }}
npm-token:
description: 'Your Npm Publish token, if you do not wish to publish to Npm, skip this'
required: false
build-command:
description: 'The bash command to execute after the version bump and before opening the PR'
required: false
optic-url:
description: 'URL if you have a custom application that serves OTP'
required: false
default: 'https://optic-zf3votdk5a-ew.a.run.app/api/generate/'
optic-token:
description: 'Your Optic token. You can add your Npm secret to the Optic app, generate a new token and pass it to this input. Required only if you want to pubish to Npm and have MFA enabled for your account'
required: false
actor-name:
description: 'The name you want to see in the new release commit.'
required: false
default: '${{ github.actor }}'
actor-email:
description: 'The email you want to see in the new release commit'
required: false
default: '[email protected]'
semver:
description: 'The semver to use for this new release'
required: true
default: 'patch'
npm-tag:
description: 'If you want to release to the Npm with a custom tag, pass it here'
required: false
default: 'latest'
api-url:
description: 'Url of the API where the application is running'
required: false
default: 'https://optic-release-automation.nearform.com/'
app-name:
description: 'Name of the github app that authors optic PRs in the following format: `app-name[bot]`'
required: false
default: 'optic-release-automation[bot]'
sync-semver-tags:
description: 'If you want to keep the major and minor versions tag synced to the latest appropriate commit'
required: false
default: 'false'
commit-message:
description: 'The commit message template. The keyword "{version}" will be replaced with the new version'
required: false
default: 'Release {version}'
revert-commit-after-failure:
description: 'If the release fails while publishing to NPM and to GitHub, setting this flag to "true", will revert the release commit. When using this flag, make sure the action is able to push directly to the main branch'
required: false
type: boolean
default: 'false'
notify-linked-issues:
description: 'If the flag is set to "true", a comment will be posted on each issue that is linked to the pull requests included in each release. The default setting is "true".'
required: false
type: boolean
default: 'true'
artifact-path:
description: 'Set this input to the distribution folder or file you want to add as the main asset for your release. It will be downloadable from the release page and a preview of it will be available in the pull request.'
required: false
version-prefix:
description: 'A prefix to apply to the version number, which reflects in the tag and GitHub release names'
required: true
default: 'v'
prerelease-prefix:
description: 'A prefix to apply to the prerelease version number'
required: false
base-tag:
description: 'This input allows you to specify a base release and will include all changes made in releases between the base release and the latest release'
required: false
provenance:
description: 'If true, NPM >9.5 will attempt to generate and display a "provenance" badge. See https://docs.npmjs.com/generating-provenance-statements'
required: false
type: boolean
default: 'false'
access:
description: 'If defined, sets package to public or restricted via `--access` flag on `npm publish`. Supported values are "restricted" or "public".'
required: false
runs:
using: 'composite'
steps:
- name: Checkout the fresh project
uses: actions/checkout@v4
- name: Configure git
run: |
git config --global user.email "${{ inputs.actor-email }}"
git config --global user.name "${{ inputs.actor-name }}"
shell: 'bash'
- name: Version bump
uses: actions/github-script@v7
id: version-bump
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
result-encoding: string
github-token: ${{ inputs.github-token }}
script: |
const { bumpVersion } = require('${{ github.action_path }}/dist/index.js')
return await bumpVersion({ inputs: ${{ toJSON(inputs) }} })
- name: Build the package
if: ${{ inputs.build-command }}
run: |
node -v
npm -v
${{ inputs.build-command }}
shell: 'bash'
- name: Commit and open PR
uses: actions/github-script@v7
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
github-token: ${{ inputs.github-token }}
script: |
const { runAction } = require('${{ github.action_path }}/dist/index.js')
await runAction({ github, context, inputs: ${{ toJSON(inputs) }}, packageVersion: ${{ steps.version-bump.outputs.result }} })
- name: Release the package
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
github-token: ${{ inputs.github-token }}
script: |
const { runAction } = require('${{ github.action_path }}/dist/index.js')
await runAction({ github, context, inputs: ${{ toJSON(inputs) }} })