Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and Typing Cleanup #153

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ DISABLE:
# https://megalinter.io/latest/config-activation/
DISABLE_LINTERS:
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
- REPOSITORY_KICS
- REPOSITORY_TRIVY
- TYPESCRIPT_STANDARD

# List of enabled but not blocking linters keys
Expand Down Expand Up @@ -135,7 +137,7 @@ VALIDATE_ALL_CODEBASE: true
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.yml
JAVASCRIPT_PRETTIER_CONFIG_FILE: prettierrc.yml
JSON_PRETTIER_CONFIG_FILE: prettierrc.yml
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdownlint.yml
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdown-lint.yml
TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.yml
TYPESCRIPT_PRETTIER_CONFIG_FILE: .prettierrc.yml
YAML_PRETTIER_CONFIG_FILE: .prettierrc.yml
Expand Down
77 changes: 37 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# IssueOps Releaser

[![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)
[![CodeQL](https://github.com/issue-ops/releaser/actions/workflows/codeql.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/codeql.yml)
[![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)
[![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)
[![Linter](https://github.com/issue-ops/releaser/actions/workflows/linter.yml/badge.svg)](https://github.com/issue-ops/releaser/actions/workflows/linter.yml)
[![Code Coverage](./badges/coverage.svg)](./badges/coverage.svg)
![Check dist/](https://github.com/issue-ops/releaser/actions/workflows/check-dist.yml/badge.svg)
![CodeQL](https://github.com/issue-ops/releaser/actions/workflows/codeql.yml/badge.svg)
![Continuous Integration](https://github.com/issue-ops/releaser/actions/workflows/continuous-integration.yml/badge.svg)
![Continuous Delivery](https://github.com/issue-ops/releaser/actions/workflows/continuous-delivery.yml/badge.svg)
![Linter](https://github.com/issue-ops/releaser/actions/workflows/linter.yml/badge.svg)
![Code Coverage](./badges/coverage.svg)

Handle releases for GitHub repositories

Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
ref: main

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

on:
pull_request:
types:
- closed
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'The version to release'
required: true
default: 'v0.0.0'

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

# This could also be a GitHub Actions variable
env:
RELEASE_VERSION: v1.2.3

jobs:
release:
name: Release Version
Expand All @@ -118,44 +115,44 @@ jobs:
if: ${{ github.event.pull_request.merged == true }}

steps:
# Checkout the repository with fetch-tags set to true
# Checkout the repository, making sure to set fetch-depth to 0 and
# fetch-tags set to true
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

# Use the version from the environment variable for the release
# Use the version from the input variable
- name: Create Release
id: create-release
uses: issue-ops/[email protected]
with:
tag: ${{ env.RELEASE_VERSION }}
tag: ${{ inputs.version }}
```

## Inputs

| Input | Description |
| ------------------------ | ------------------------------------------------- |
| `draft` | Whether or not the release should be a draft |
| | Default: `false` |
| `generate_release_notes` | Whether or not to generate release notes |
| | Default: `true` |
| `github_token` | The token to use for authentication |
| | Default: `${{ github.token }}` |
| `name` | The name of the release |
| | Default: The `tag` value |
| `notes` | The release notes, prepended to the generated |
| | notes if `generate_release_notes` is `true` |
| `owner` | The owner of the repository |
| | Default: The owner of the workflow repository |
| `prerelease` | Whether or not the release should be a prerelease |
| | Default: `false` |
| `repo` | The repository to create the release in |
| | Default: The workflow repository |
| `tag` | The tag to create or reference for the release |
| `target_commitish` | The branch or commit SHA to tag for the release |
| | Not required if the tag already exists |
| Input | Description |
| ------------------------ | ----------------------------------------------------------------------------------------- |
| `draft` | Whether or not the release should be a draft |
| | Default: `false` |
| `generate_release_notes` | Whether or not to generate release notes |
| | Default: `true` |
| `github_token` | The token to use for authentication |
| | Default: `${{ github.token }}` |
| `name` | The name of the release |
| | Default: The `tag` value |
| `notes` | The release notes, prepended to the generated notes if `generate_release_notes` is `true` |
| `owner` | The owner of the repository |
| | Default: The owner of the workflow repository |
| `prerelease` | Whether or not the release should be a prerelease |
| | Default: `false` |
| `repo` | The repository to create the release in |
| | Default: The workflow repository |
| `tag` | The tag to create or reference for the release |
| `target_commitish` | The branch or commit SHA to tag for the release (not required if the tag already exists) |

## Outputs

Expand Down
4 changes: 3 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ describe('main.ts', () => {
new Error('Error creating release')
)

await expect(main.run()).rejects.toThrow('Error creating release')
await main.run()

expect(core.setFailed).toHaveBeenCalledWith('Error creating release')
})
})
5 changes: 2 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions dist/interfaces.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "releaser",
"description": "Handle releases for GitHub repositories",
"version": "2.0.0",
"version": "2.1.0",
"type": "module",
"author": "Nick Alteen <[email protected]>",
"homepage": "https://github.com/issue-ops/releaser#readme",
Expand Down
15 changes: 15 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* GitHub Release
*/
export interface CreateReleaseOptions {
owner: string
repo: string
tag_name: string
name: string
draft: boolean
prerelease: boolean
generate_release_notes: boolean
target_commitish?: string
body?: string
}

/**
* GitHub Release
*/
Expand Down
11 changes: 5 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import { Octokit } from '@octokit/rest'
import { Release } from './interfaces.js'
import type { CreateReleaseOptions, Release } from './interfaces.js'

export async function run(): Promise<void> {
// Get the inputs
Expand Down Expand Up @@ -38,8 +38,7 @@ export async function run(): Promise<void> {

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

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

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

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