diff --git a/README.md b/README.md index 85ed92a..34a9109 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,34 @@ It procuces an output similar to below - [#4526](https://github.com/AFNetworking/AFNetworking/pull/4526): Remove unnecessary __block by [kinarobin](https://github.com/kinarobin) +### Action + +When using the github action these are the inputs and outputs for the tool + +#### Inputs + +| Input | Default | Description | +--- | --- | --- +| token | github.token | The token used for github API | +| outputFile | * | The file to output to. If not provided only the action output is generated | +| since | * | The tag to generate the changelog since | +| sinceLatestRelease | * | `true`/`false` whether to generate since the latest release | +| complete | * | `true`/`false` whether to generate the complete changelog | +| nextTag | * | The next tag to bundle all the untagged pull requests into | +| filter | * | Filter regular expression to ignore all matching pull requests from the changelog | +| labels | * | Labels to group pull requests by | +| excludedLabels | * | Labels to exclude from the changelog | +| branch | * | The target branch for the changelog. When provided only pull requests merged into the branch are included | +| includeUntagged | `true` | `true`/`false` whether to include untagged pull requests in the changelog | +| verbose | * | `true`/`false` Whether to enable verbose logging. The verbose logs also become part of the outputs | +| use-compiled | `true` | `true`/`false` Whether to use the precompiled executable or not. This is never used for linux. | + +#### Outputs + +| Input | Description | +--- | --- | --- +| changelog | The changelog generated during the run | + +#### Environment Variables + +`CHANGELOG_GENERATED_VALUE` : Contains the changelog generated during run diff --git a/Sources/ChangeLogGenerator/Fetcher/GitHub.swift b/Sources/ChangeLogGenerator/Fetcher/GitHub.swift index 2334f3a..b63ff9a 100644 --- a/Sources/ChangeLogGenerator/Fetcher/GitHub.swift +++ b/Sources/ChangeLogGenerator/Fetcher/GitHub.swift @@ -178,7 +178,7 @@ extension GitHub { /// - maximumNumberOfPages: The maximum number of pages to fetch func fetchComparison(from base: String, to head: String, maximumNumberOfPages: Int? = nil) async throws -> Comparison { let url: URL = try createBaseUrl(for: .compare(base, head)) - Logger.log("Fetching comparison from \(url)") + Logger.log(level: .verbose, "Fetching comparison from \(url)") let fetcher = ComparisonFetcher( url: url, headers: headers, diff --git a/Sources/ChangeLogGenerator/Generator/Generator.swift b/Sources/ChangeLogGenerator/Generator/Generator.swift index ee4edd4..fbf08ae 100644 --- a/Sources/ChangeLogGenerator/Generator/Generator.swift +++ b/Sources/ChangeLogGenerator/Generator/Generator.swift @@ -75,7 +75,7 @@ public struct Generator { /// - maximumNumberOfPages: maximum number of pages to load /// - completion: will finish with a changelog string public func generateChangeLogSince(tag: String, on branch: String? = nil) async throws -> String { - Logger.log("generating since \(tag) on branch \(branch ?? "nil")") + Logger.log(level: .verbose, "generating since \(tag) on branch \(branch ?? "nil")") let tags = try await GitHub(repository: repository, token: token) .fetch(from: .tags, maximumNumberOfPages: maximumNumberOfPages) { (tags: [Tag]) -> Bool in tags.contains { $0.name == tag } == false diff --git a/Sources/changelog/Commands/Generate.swift b/Sources/changelog/Commands/Generate.swift index cfeb63f..5ee0f1b 100644 --- a/Sources/changelog/Commands/Generate.swift +++ b/Sources/changelog/Commands/Generate.swift @@ -1,6 +1,6 @@ // // Generate.swift -// +// // // Created by Mahmood Tahir on 2021-01-19. // @@ -126,22 +126,22 @@ struct Generate: ParsableCommand { let changelog: String switch type { case .complete: - Logger.log("Fetch complete changelog") + Logger.log(level: .verbose, "Fetch complete changelog") changelog = try await generator.generateCompleteChangeLog() case .sinceLatestRelease: - Logger.log("Fetch since latest release") + Logger.log(level: .verbose, "Fetch since latest release") changelog = try await generator.generateChangeLogSinceLatestRelease(on: branch) case .sinceTag: guard let tag = tag else { throw GenerateError.missingTag } - Logger.log("Fetch since \(tag)") + Logger.log(level: .verbose, "Fetch since \(tag)") changelog = try await generator.generateChangeLogSince(tag: tag, on: branch) case .milestone: guard let milestone = milestone else { throw GenerateError.missingMilestone } - Logger.log("Fetch milestone \(milestone)") + Logger.log(level: .verbose, "Fetch milestone \(milestone)") changelog = try await generator.generateChangeLogFor(milestone: milestone) } diff --git a/action.yml b/action.yml index b2fa49e..ac32c0b 100644 --- a/action.yml +++ b/action.yml @@ -61,12 +61,13 @@ inputs: outputs: changelog: description: the generated changelog - value: ${{ steps.generate.outputs.changelog }} + value: ${{ steps.set-output.outputs.changelog }} runs: using: "composite" steps: - - id: generate + - name: Generate + id: generate run: | repository="${{ github.repository }}" token="${{ inputs.token }}" @@ -177,11 +178,19 @@ runs: changelog=$("${command[@]}") - # Escape the special characters so that multiline output is supported - changelog="${changelog//'%'/'%25'}" - changelog="${changelog//$'\n'/'%0A'}" - changelog="${changelog//$'\r'/'%0D'}" + # Add output to environment - echo "::set-output name=changelog::$changelog" + echo 'CHANGELOG_GENERATED_VALUE<> $GITHUB_ENV + echo "$changelog" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV shell: bash + + - name: Set output + id: set-output + uses: actions/github-script@v6 + with: + script: | + const { CHANGELOG_GENERATED_VALUE } = process.env + + core.setOutput('changelog', CHANGELOG_GENERATED_VALUE) diff --git a/changelog b/changelog index a9cd975..9e21655 100755 Binary files a/changelog and b/changelog differ