Skip to content

Commit

Permalink
fix!: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed May 18, 2024
1 parent b8cb153 commit 24e551e
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 1,038 deletions.
70 changes: 5 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ jobs:


action:
strategy:
fail-fast: false
matrix:
set:
- '0'
- '1'
- '2'

runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -74,68 +66,17 @@ jobs:
id: action
uses: ./
with:
changelog_path: ./tests/data/set${{ matrix.set }}/CHANGELOG.md
fail_on_events_api_error: false # these scenarios do not exist in the GitHub events api
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Print action outputs
shell: bash
run: |
echo "changelog_exists: ${{ steps.action.outputs.changelog_exists }}"
echo "changelog_changes: ${{ steps.action.outputs.changelog_changes }}"
echo "changelog_date: ${{ steps.action.outputs.changelog_date }}"
echo "changelog_url: ${{ steps.action.outputs.changelog_url }}"
echo "changelog_version: ${{ steps.action.outputs.changelog_version }}"
echo "changelog_release_exists: ${{ steps.action.outputs.changelog_release_exists }}"
echo "publish_stable_release: ${{ steps.action.outputs.publish_stable_release }}"
echo "release_version: ${{ steps.action.outputs.release_version }}"
echo "publish_release: ${{ steps.action.outputs.publish_release }}"
echo "release_commit: ${{ steps.action.outputs.release_commit }}"
echo "release_generate_release_notes: ${{ steps.action.outputs.release_generate_release_notes }}"
echo "release_tag: ${{ steps.action.outputs.release_tag }}"
- name: Verify changelog_exists
shell: bash
run: |
if [[ "${{ steps.action.outputs.changelog_exists }}" != "True" ]]; then
if [[ "${{ matrix.set }}" != "0" ]]; then
echo "changelog_exists is not true"
exit 1
fi
fi
- name: Verify changelog_changes
shell: bash
run: |
expected_changes=$(cat ./tests/data/set${{ matrix.set }}/changes.txt)
if [[ "${{ steps.action.outputs.changelog_changes }}" != "${expected_changes}" ]]; then
echo "changelog_changes does not match expected"
exit 1
fi
- name: Verify changelog_date
shell: bash
run: |
expected_date=$(cat ./tests/data/set${{ matrix.set }}/date.txt)
if [[ "${{ steps.action.outputs.changelog_date }}" != "${expected_date}" ]]; then
echo "changelog_date does not match expected"
exit 1
fi
- name: Verify changelog_url
shell: bash
run: |
expected_url=$(cat ./tests/data/set${{ matrix.set }}/url.txt)
if [[ "${{ steps.action.outputs.changelog_url }}" != "${expected_url}" ]]; then
echo "changelog_url does not match expected"
exit 1
fi
- name: Verify changelog_version
shell: bash
run: |
expected_version=$(cat ./tests/data/set${{ matrix.set }}/version.txt)
if [[ "${{ steps.action.outputs.changelog_version }}" != "${expected_version}" ]]; then
echo "changelog_version does not match expected"
exit 1
fi
echo "release_version: ${{ steps.action.outputs.release_version }}"
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand All @@ -159,10 +100,9 @@ jobs:
with:
allowUpdates: false
artifacts: ''
body: ''
discussionCategory: announcements
generateReleaseNotes: true
name: ${{ steps.setup-release.outputs.release_tag }}
prerelease: ${{ steps.setup-release.outputs.publish_stable_release != 'true' }}
prerelease: true
tag: ${{ steps.setup-release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}
160 changes: 17 additions & 143 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
[![GitHub Workflow Status (CI)](https://img.shields.io/github/actions/workflow/status/lizardbyte/setup-release-action/ci.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/setup-release-action/actions/workflows/ci.yml?query=branch%3Amaster)
[![Codecov](https://img.shields.io/codecov/c/gh/LizardByte/setup-release-action.svg?token=joIISKAJtv&style=for-the-badge&logo=codecov&label=codecov)](https://app.codecov.io/gh/LizardByte/setup-release-action)

A reusable action to setup release inputs for GitHub Actions. This action is tailored to the
A reusable action to set up release inputs for GitHub Actions. This action is tailored to the
@LizardByte organization, but can be used by anyone if they follow the same conventions.

The action does the following:

- Get the latest push event to the default branch
- Check if `CHANGELOG.md` file exists
- If it does, parse the file and extract the following properties
- Latest version
- Latest version date
- Latest version changes
- Latest version release url
- If the changelog exists, check if the latest release is already GitHub release
- Setup the correct type of release based on the conditions above
- Provide some outputs to use for the release step

## Simple Usage
```yaml
Expand All @@ -32,144 +25,25 @@ The action does the following:
id: setup_release
uses: LizardByte/setup-release-action@master
with:
changelog_path: ./docs/CHANGELOG.md
fail_on_events_api_error: true
github_token: ${{ secrets.GITHUB_TOKEN }}
```
## Inputs
| Name | Description | Default | Required |
|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|----------|
| changelog_path | Path to the changelog file, relative to the GitHub workspace. | `CHANGELOG.md` | `false` |
| dotnet | Whether to create a dotnet version (4 components, e.g. yyyy.mmdd.hhmm.ss). | `false` | `false` |
| event_api_max_attempts | Maximum number of attempts for the GitHub Events API. | `5` | `false` |
| fail_on_events_api_error | Whether to fail if the GitHub Events API returns an error. Will only fail for push events. | `true` | `false` |
| github_token | GitHub token to use for API requests. | | `true` |
| include_tag_prefix_in_output | Whether to include the tag prefix in the output. | `true` | `false` |
| tag_prefix | The tag prefix. This will be used when searching for existing releases in GitHub API. This should not be included in the version within the changelog. | `v` | `false` |
| Name | Description | Default | Required |
|------------------------------|--------------------------------------------------------------------------------------------|---------|----------|
| dotnet | Whether to create a dotnet version (4 components, e.g. yyyy.mmdd.hhmm.ss). | `false` | `false` |
| event_api_max_attempts | Maximum number of attempts for the GitHub Events API. | `10` | `false` |
| fail_on_events_api_error | Whether to fail if the GitHub Events API returns an error. Will only fail for push events. | `true` | `false` |
| github_token | GitHub token to use for API requests. | | `true` |
| include_tag_prefix_in_output | Whether to include the tag prefix in the output. | `true` | `false` |
| tag_prefix | The tag prefix. This will be used when searching for existing releases in GitHub API. | `v` | `false` |

## Outputs
| Name | Description |
|--------------------------------|------------------------------------------------------------------------------------|
| changelog_changes | The changes for the latest version in the changelog |
| changelog_date | The date for the latest version in the changelog |
| changelog_exists | Whether or not the changelog file exists |
| changelog_release_exists | Whether or not the latest version is a GitHub release |
| changelog_url | The url for the latest version in the changelog |
| changelog_version | The version for the latest version in the changelog |
| publish_pre_release | Whether or not to publish a pre-release. The opposite of `publish_stable_release`. |
| publish_release | Whether or not to publish a release |
| publish_stable_release | Whether or not to publish a stable release. The opposite of `publish_pre_release`. |
| release_body | The body for the release |
| release_commit | The commit hash for the release |
| release_generate_release_notes | Whether or not to generate release notes for the release |
| release_tag | The tag for the release (i.e. `release_version` with prefix) |
| release_version | The version for the release (i.e. `yyyy.mmdd.hhmmss` or `changelog_version`) |

## Basic Flow
```mermaid
graph TD
subgraph "Setup Release"
A[Get Push Event Details from API]
B[Changelog Exists?]
C[Parse Changelog]
D[Release Exists in GitHub?]
E[Prepare Release]
F[Prepare Pre-Release]
G[Set GitHub Outputs]
end
A --> B
B --> |True| C
C --> D
B --> |False| E
D --> |False| E
D --> |True| F
E --> G
F --> G
```

## Expected Outputs
```mermaid
graph TD
subgraph "Set GitHub Outputs"
A1{Changelog Exists?}
A2(changelog_exists = 'True')
A3(changelog_changes = \list of changes\)
A4(changelog_date = \date from changelog\)
A5(changelog_url = \url from changelog\)
A6(changelog_version = \version from changelog\)
B1(changelog_exists = 'False')
B2(changelog_changes = '')
B3(changelog_date = '')
B4(changelog_url = '')
B5(changelog_version = '')
C1(release_commit = \commit\ )
D1{GitHub Release Exists?}
D2(changelog_release_exists = 'true')
D3(publish_pre_release = 'true')
D4(publish_stable_release = 'false')
D5(release_body = '')
D6(release_generate_release_notes = 'true')
D7(release_version = 'yyyy.md.hhmmss')
D8(release_tag = `release_version`)

E1(changelog_release_exists = 'false')
E2(publish_pre_release = 'false')
E3(publish_stable_release = 'true')
E4(release_body = changelog_changes if changelog exists else '')
E5(release_generate_release_notes = 'false' if changelog exists else 'true')
E6(release_version = \changelog version\)
E7(release_tag = `release_version`)

F1{Push Event?}
F2(publish_release = 'true')
F3(publish_release = 'false')
end

A1 --> |True| A2
A2 --> A3
A3 --> A4
A4 --> A5
A5 --> A6
A6 --> C1

A1 --> |False| B1
B1 --> B2
B2 --> B3
B3 --> B4
B4 --> B5
B5 --> C1

C1--> D1

D1 --> |True| D2
D2 --> D3
D3 --> D4
D4 --> D5
D5 --> D6
D6 --> D7
D7 --> D8
D8 --> F1

D1 --> |False| E1
E1 --> E2
E2 --> E3
E3 --> E4
E4 --> E5
E5 --> E6
E6 --> E7
E7 --> F1

F1 --> |True| F2
F1 --> |False| F3

```
| Name | Description |
|--------------------------------|--------------------------------------------------------------------|
| publish_release | Whether or not to publish a release |
| release_commit | The commit hash for the release |
| release_generate_release_notes | Whether to generate release notes for the release. (Always `true`) |
| release_tag | The tag for the release (i.e. `release_version` with prefix) |
| release_version | The version for the release (i.e. `yyyy.mmdd.hhmmss`) |
34 changes: 10 additions & 24 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
---
name: "Setup Release"
description: "Parse the changelog and setup the release parameters."
description: "Set up the release parameters."
author: "LizardByte"

inputs:
changelog_path:
description: "Path to the changelog file, relative to the GitHub workspace."
default: "CHANGELOG.md"
required: false
dotnet:
description: "Whether to create a dotnet version (4 components, e.g. yyyy.mmdd.hhmm.ss)."
default: 'false'
Expand All @@ -28,31 +24,21 @@ inputs:
default: 'true'
required: false
tag_prefix:
description: |
The tag prefix. This will be used when searching for existing releases in GitHub API.
This should not be included in the version within the changelog.
description: "The tag prefix. This will be used when searching for existing releases in GitHub API."
default: "v"
required: false

outputs:
changelog_changes:
description: "List of changes in the latest version."
changelog_date:
description: "Date of the latest version in the format: `yyyy.m.d`"
changelog_exists:
description: "Whether the changelog exists."
changelog_release_exists:
description: "Whether the release exists in GitHub."
changelog_url:
description: "URL to the latest version in the changelog."
changelog_version:
description: "Latest version in the changelog."
publish_stable_release:
description: "Whether to publish a stable release."
publish_release:
description: "Whether to publish a release."
release_commit:
description: "The commit hash for the release."
release_generate_release_notes:
description: "Whether to generate release notes for the release. (Always `true`)"
release_tag:
description: "Tag of the release to make. e.g. `vYYYY.M.D-Build` or `vYYYY.M.D`"
description: "The tag for the release (i.e. `release_version` with prefix)"
release_version:
description: "Version of the release to make."
description: "The version for the release (i.e. `yyyy.mmdd.hhmmss`)"

runs:
using: "docker"
Expand Down
Loading

0 comments on commit 24e551e

Please sign in to comment.