-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update release tag to v0.1.2 * Update release file path * Update actions/checkout version in gh-release workflow * Update pull_request types in gh-release.yaml * Add gh-release-preview workflow * Update actions/checkout version to v4 * Add actions-gh-release files * Update GitHub Actions workflow * Add GitHub Actions workflow for creating releases * Add GitHub release action and related files * Update GitHub Actions workflow for gh-release * Add permissions for contents and issues * Update permissions in gh-release-preview.yml * Add GitHub App token for authentication * Update GitHub Actions workflow and file permissions * Remove commented out code in gh-release-preview.yml
- Loading branch information
Showing
20 changed files
with
2,293 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/** -diff linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Dependency directory | ||
node_modules | ||
|
||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# OS metadata | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Ignore built ts files | ||
__tests__/runner/* | ||
lib/**/* | ||
|
||
gh-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM golang:1.20.5-alpine3.18 | ||
|
||
RUN apk update && apk add git | ||
|
||
COPY . /app | ||
|
||
RUN cd /app && \ | ||
go build -o /gh-release . && \ | ||
chmod +x /gh-release | ||
|
||
ENTRYPOINT ["/gh-release"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.PHONY: build | ||
build: | ||
go build -o gh-release . | ||
|
||
.PHONY: test | ||
test: | ||
go test ./... | ||
|
||
.PHONY: dep | ||
dep: | ||
go mod tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: 'Create GitHub Release' | ||
description: 'Create new releases when any specified RELEASE files were modified.' | ||
author: 'PipeCD team' | ||
branding: | ||
icon: 'tag' | ||
color: 'green' | ||
|
||
inputs: | ||
release_file: | ||
description: 'The path to the RELEASE file or pattern to match one or multiple RELEASE files.' | ||
required: true | ||
token: | ||
description: 'The GITHUB_TOKEN secret.' | ||
required: true | ||
output_releases_file_path: | ||
description: 'The path to output the list of releases formatted in JSON.' | ||
required: false | ||
|
||
outputs: | ||
releases: | ||
description: 'The list of releases formatted in JSON.' | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- release-file=${{ inputs.release_file }} | ||
- token=${{ inputs.token }} | ||
- output-releases-file-path=${{ inputs.output_releases_file_path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2024 The PipeCD Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
const ( | ||
successBadgeURL = `<!-- RELEASE --> | ||
[![RELEASE](https://img.shields.io/static/v1?label=GitHub&message=RELEASE&color=success&style=flat)](https://github.com/pipe-cd/actions-gh-release) | ||
` | ||
) | ||
|
||
func makeCommentBody(proposals []ReleaseProposal, exists []ReleaseProposal) string { | ||
var b strings.Builder | ||
b.WriteString(successBadgeURL) | ||
|
||
if len(proposals) == 0 { | ||
if len(exists) == 0 { | ||
fmt.Fprintf(&b, "No GitHub releases will be created one this pull request got merged. Because this pull request did not modified any RELEASE files.\n") | ||
return b.String() | ||
} | ||
|
||
fmt.Fprintf(&b, "No GitHub releases will be created one this pull request got merged. Because the following tags were already created before.\n") | ||
for _, p := range exists { | ||
fmt.Fprintf(&b, "- %s\n", p.Tag) | ||
} | ||
return b.String() | ||
} | ||
|
||
b.WriteString(fmt.Sprintf("The following %d GitHub releases will be created once this pull request got merged.\n", len(proposals))) | ||
for _, p := range proposals { | ||
fmt.Fprintf(&b, "\n") | ||
fmt.Fprintf(&b, p.ReleaseNote) | ||
fmt.Fprintf(&b, "\n") | ||
} | ||
|
||
if len(exists) > 0 { | ||
fmt.Fprintf(&b, "The following %d releases will be skipped because they were already created before.\n", len(exists)) | ||
for _, p := range exists { | ||
fmt.Fprintf(&b, "- %s\n", p.Tag) | ||
} | ||
} | ||
|
||
return b.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2024 The PipeCD Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMakeCommentBody(t *testing.T) { | ||
testcases := []struct { | ||
name string | ||
proposals []ReleaseProposal | ||
exists []ReleaseProposal | ||
expected string | ||
}{ | ||
{ | ||
name: "no release", | ||
expected: "testdata/no-release-comment.txt", | ||
}, | ||
{ | ||
name: "one release", | ||
proposals: []ReleaseProposal{ | ||
ReleaseProposal{ | ||
ReleaseNote: "Release note for tag 1", | ||
}, | ||
}, | ||
expected: "testdata/one-release-comment.txt", | ||
}, | ||
{ | ||
name: "multiple releases", | ||
proposals: []ReleaseProposal{ | ||
ReleaseProposal{ | ||
ReleaseNote: "Release note for tag 1", | ||
}, | ||
ReleaseProposal{ | ||
ReleaseNote: "Release note for tag 2", | ||
}, | ||
}, | ||
expected: "testdata/multi-release-comment.txt", | ||
}, | ||
} | ||
|
||
for _, tc := range testcases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := makeCommentBody(tc.proposals, tc.exists) | ||
expected, err := testdata.ReadFile(tc.expected) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, string(expected), got) | ||
}) | ||
} | ||
} |
Oops, something went wrong.