Skip to content

Commit 044382c

Browse files
authored
Merge pull request #153 from issue-ops/ncalteen/formatting
Formatting and Typing Cleanup
2 parents 17a5066 + b442e3a commit 044382c

10 files changed

+83
-55
lines changed

.mega-linter.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ DISABLE:
2020
# https://megalinter.io/latest/config-activation/
2121
DISABLE_LINTERS:
2222
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
23+
- REPOSITORY_KICS
24+
- REPOSITORY_TRIVY
2325
- TYPESCRIPT_STANDARD
2426

2527
# List of enabled but not blocking linters keys
@@ -135,7 +137,7 @@ VALIDATE_ALL_CODEBASE: true
135137
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.yml
136138
JAVASCRIPT_PRETTIER_CONFIG_FILE: prettierrc.yml
137139
JSON_PRETTIER_CONFIG_FILE: prettierrc.yml
138-
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.yml
140+
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdown-lint.yml
139141
TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.yml
140142
TYPESCRIPT_PRETTIER_CONFIG_FILE: .prettierrc.yml
141143
YAML_PRETTIER_CONFIG_FILE: .prettierrc.yml

README.md

+37-40
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# IssueOps Releaser
22

3-
[![Check dist/](https://github.com/issue-ops/releaser/actions/workflows/check-dist.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/check-dist.yml)
4-
[![CodeQL](https://github.com/issue-ops/releaser/actions/workflows/codeql.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/codeql.yml)
5-
[![Continuous Integration](https://github.com/issue-ops/releaser/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/continuous-integration.yml)
6-
[![Continuous Delivery](https://github.com/issue-ops/releaser/actions/workflows/continuous-delivery.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/continuous-delivery.yml)
7-
[![Linter](https://github.com/issue-ops/releaser/actions/workflows/linter.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/linter.yml)
8-
[![Code Coverage](./badges/coverage.svg)](./badges/coverage.svg)
3+
![Check dist/](https://github.com/issue-ops/releaser/actions/workflows/check-dist.yml/badge.svg)
4+
![CodeQL](https://github.com/issue-ops/releaser/actions/workflows/codeql.yml/badge.svg)
5+
![Continuous Integration](https://github.com/issue-ops/releaser/actions/workflows/continuous-integration.yml/badge.svg)
6+
![Continuous Delivery](https://github.com/issue-ops/releaser/actions/workflows/continuous-delivery.yml/badge.svg)
7+
![Linter](https://github.com/issue-ops/releaser/actions/workflows/linter.yml/badge.svg)
8+
![Code Coverage](./badges/coverage.svg)
99

1010
Handle releases for GitHub repositories
1111

@@ -78,7 +78,7 @@ jobs:
7878
ref: main
7979

8080
# Use the version output from the previous step for the release
81-
# Prepend a 'v' to the beginning (e.g. 'v1.2.3')
81+
# Prepends a 'v' to the beginning (e.g. 'v1.2.3')
8282
- name: Create Release
8383
id: create-release
8484
uses: issue-ops/[email protected]
@@ -95,20 +95,17 @@ Actions variable.
9595
name: Continuous Delivery
9696

9797
on:
98-
pull_request:
99-
types:
100-
- closed
101-
branches:
102-
- main
98+
workflow_dispatch:
99+
inputs:
100+
version:
101+
description: 'The version to release'
102+
required: true
103+
default: 'v0.0.0'
103104

104105
# This is required to be able to update tags and create releases
105106
permissions:
106107
contents: write
107108

108-
# This could also be a GitHub Actions variable
109-
env:
110-
RELEASE_VERSION: v1.2.3
111-
112109
jobs:
113110
release:
114111
name: Release Version
@@ -118,44 +115,44 @@ jobs:
118115
if: ${{ github.event.pull_request.merged == true }}
119116

120117
steps:
121-
# Checkout the repository with fetch-tags set to true
118+
# Checkout the repository, making sure to set fetch-depth to 0 and
119+
# fetch-tags set to true
122120
- name: Checkout
123121
id: checkout
124122
uses: actions/checkout@v4
125123
with:
124+
fetch-depth: 0
126125
fetch-tags: true
127126

128-
# Use the version from the environment variable for the release
127+
# Use the version from the input variable
129128
- name: Create Release
130129
id: create-release
131130
uses: issue-ops/[email protected]
132131
with:
133-
tag: ${{ env.RELEASE_VERSION }}
132+
tag: ${{ inputs.version }}
134133
```
135134
136135
## Inputs
137136
138-
| Input | Description |
139-
| ------------------------ | ------------------------------------------------- |
140-
| `draft` | Whether or not the release should be a draft |
141-
| | Default: `false` |
142-
| `generate_release_notes` | Whether or not to generate release notes |
143-
| | Default: `true` |
144-
| `github_token` | The token to use for authentication |
145-
| | Default: `${{ github.token }}` |
146-
| `name` | The name of the release |
147-
| | Default: The `tag` value |
148-
| `notes` | The release notes, prepended to the generated |
149-
| | notes if `generate_release_notes` is `true` |
150-
| `owner` | The owner of the repository |
151-
| | Default: The owner of the workflow repository |
152-
| `prerelease` | Whether or not the release should be a prerelease |
153-
| | Default: `false` |
154-
| `repo` | The repository to create the release in |
155-
| | Default: The workflow repository |
156-
| `tag` | The tag to create or reference for the release |
157-
| `target_commitish` | The branch or commit SHA to tag for the release |
158-
| | Not required if the tag already exists |
137+
| Input | Description |
138+
| ------------------------ | ----------------------------------------------------------------------------------------- |
139+
| `draft` | Whether or not the release should be a draft |
140+
| | Default: `false` |
141+
| `generate_release_notes` | Whether or not to generate release notes |
142+
| | Default: `true` |
143+
| `github_token` | The token to use for authentication |
144+
| | Default: `${{ github.token }}` |
145+
| `name` | The name of the release |
146+
| | Default: The `tag` value |
147+
| `notes` | The release notes, prepended to the generated notes if `generate_release_notes` is `true` |
148+
| `owner` | The owner of the repository |
149+
| | Default: The owner of the workflow repository |
150+
| `prerelease` | Whether or not the release should be a prerelease |
151+
| | Default: `false` |
152+
| `repo` | The repository to create the release in |
153+
| | Default: The workflow repository |
154+
| `tag` | The tag to create or reference for the release |
155+
| `target_commitish` | The branch or commit SHA to tag for the release (not required if the tag already exists) |
159156

160157
## Outputs
161158

__tests__/main.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ describe('main.ts', () => {
113113
new Error('Error creating release')
114114
)
115115

116-
await expect(main.run()).rejects.toThrow('Error creating release')
116+
await main.run()
117+
118+
expect(core.setFailed).toHaveBeenCalledWith('Error creating release')
117119
})
118120
})

dist/index.js

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/interfaces.d.ts

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "releaser",
33
"description": "Handle releases for GitHub repositories",
4-
"version": "2.0.0",
4+
"version": "2.1.0",
55
"type": "module",
66
"author": "Nick Alteen <[email protected]>",
77
"homepage": "https://github.com/issue-ops/releaser#readme",

src/interfaces.ts

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* GitHub Release
3+
*/
4+
export interface CreateReleaseOptions {
5+
owner: string
6+
repo: string
7+
tag_name: string
8+
name: string
9+
draft: boolean
10+
prerelease: boolean
11+
generate_release_notes: boolean
12+
target_commitish?: string
13+
body?: string
14+
}
15+
116
/**
217
* GitHub Release
318
*/

src/main.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core'
22
import { Octokit } from '@octokit/rest'
3-
import { Release } from './interfaces.js'
3+
import type { CreateReleaseOptions, Release } from './interfaces.js'
44

55
export async function run(): Promise<void> {
66
// Get the inputs
@@ -38,8 +38,7 @@ export async function run(): Promise<void> {
3838

3939
try {
4040
// Create the API options
41-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
42-
const options: any = {
41+
const options: CreateReleaseOptions = {
4342
owner,
4443
repo,
4544
tag_name: tag,
@@ -54,7 +53,8 @@ export async function run(): Promise<void> {
5453
if (notes !== '') options.body = notes
5554

5655
// Create the release
57-
const response = await github.rest.repos.createRelease(options)
56+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
57+
const response = await github.rest.repos.createRelease(options as any)
5858

5959
core.debug(`Response: ${JSON.stringify(response, null, 2)}`)
6060

@@ -72,7 +72,6 @@ export async function run(): Promise<void> {
7272
core.setOutput('upload_url', release.upload_url)
7373
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7474
} catch (error: any) {
75-
core.setFailed(error.message)
76-
throw error
75+
return core.setFailed(error.message)
7776
}
7877
}

0 commit comments

Comments
 (0)