-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #630 from paketo-buildpacks/release-draft
Add an action to update draft release notes
- Loading branch information
Showing
22 changed files
with
1,528 additions
and
46 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
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,55 @@ | ||
name: Create Action draft-release | ||
"on": | ||
pull_request: | ||
paths: | ||
- actions/* | ||
- actions/draft-release/* | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- actions/* | ||
- actions/draft-release/* | ||
release: | ||
types: | ||
- published | ||
jobs: | ||
create-action: | ||
name: Create Action | ||
runs-on: | ||
- ubuntu-latest | ||
steps: | ||
- name: Docker login ghcr.io | ||
if: ${{ (github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork) && (github.actor != 'dependabot[bot]') }} | ||
uses: docker/login-action@v1 | ||
with: | ||
password: ${{ secrets.JAVA_GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
username: ${{ secrets.JAVA_GITHUB_USERNAME }} | ||
- uses: actions/checkout@v3 | ||
- name: Create Action | ||
run: | | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
echo "::group::Building ${TARGET}:${VERSION}" | ||
docker build \ | ||
--file actions/Dockerfile \ | ||
--build-arg "SOURCE=${SOURCE}" \ | ||
--tag "${TARGET}:${VERSION}" \ | ||
. | ||
echo "::endgroup::" | ||
if [[ "${PUSH}" == "true" ]]; then | ||
echo "::group::Pushing ${TARGET}:${VERSION}" | ||
docker push "${TARGET}:${VERSION}" | ||
echo "::endgroup::" | ||
else | ||
echo "Skipping push" | ||
fi | ||
env: | ||
PUSH: ${{ github.event_name != 'pull_request' }} | ||
SOURCE: draft-release | ||
TARGET: ghcr.io/paketo-buildpacks/actions/draft-release | ||
VERSION: main |
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
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
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 @@ | ||
**ID**: `{{ .PrimaryBuildpack.Info.ID }}` | ||
**Digest**: <!-- DIGEST PLACEHOLDER --> | ||
|
||
{{ if .NestedBuildpacks -}} | ||
#### Included Buildpackages: | ||
Name | ID | Version | ||
:--- | :- | :------ | ||
{{ range .NestedBuildpacks -}} | ||
{{ .Info.Name }} | `{{ .Info.ID }}` | `{{ .Info.Version }}` | ||
{{ end -}} | ||
{{ end -}} | ||
|
||
{{ if .PrimaryBuildpack.Stacks }} | ||
#### Supported Stacks: | ||
{{ range .PrimaryBuildpack.Stacks -}} | ||
- `{{ .ID }}` | ||
{{ end -}} | ||
{{ end }} | ||
|
||
{{ if .PrimaryBuildpack.Dependencies }} | ||
#### Dependencies: | ||
Name | Version | SHA256 | ||
:--- | :------ | :----- | ||
{{ range .PrimaryBuildpack.Dependencies -}} | ||
{{ .Name }} | `{{ .Version }}` | `{{ .SHA256 }}` | ||
{{ end }} | ||
{{ end }} | ||
{{ if .PrimaryBuildpack.OrderGroups }} | ||
<details> | ||
<summary>Order Groupings</summary> | ||
|
||
{{ range .PrimaryBuildpack.OrderGroups -}} | ||
ID | Version | Optional | ||
:- | :------ | :------- | ||
{{ range .Groups -}} | ||
`{{ .ID }}` | `{{ .Version }}` | `{{ .Optional }}` | ||
{{ end }} | ||
{{ end -}} | ||
</details> | ||
{{ end }} | ||
--- | ||
|
||
{{ range .NestedBuildpacks -}} | ||
<details> | ||
<summary>{{- .Info.Name }} {{ .Info.Version -}}</summary> | ||
|
||
**ID**: `{{ .Info.ID }}` | ||
|
||
{{ if .Stacks -}} | ||
#### Supported Stacks: | ||
{{ range .Stacks -}} | ||
- `{{ .ID }}` | ||
{{ end -}} | ||
{{ end }} | ||
{{ if .Dependencies -}} | ||
#### Dependencies: | ||
Name | Version | SHA256 | ||
:--- | :------ | :----- | ||
{{ range .Dependencies -}} | ||
{{ .Name }} | `{{ .Version }}` | `{{ .SHA256 }}` | ||
{{ end -}} | ||
{{ end -}} | ||
|
||
--- | ||
</details> | ||
{{ end }} | ||
{{ .Release.Body -}} |
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,90 @@ | ||
/* | ||
* Copyright 2018-2022 the original author or 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 | ||
* | ||
* https://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 ( | ||
_ "embed" | ||
|
||
"fmt" | ||
"io/ioutil" | ||
"path/filepath" | ||
|
||
"github.com/paketo-buildpacks/libpak/effect" | ||
"github.com/paketo-buildpacks/pipeline-builder/actions" | ||
"github.com/paketo-buildpacks/pipeline-builder/drafts" | ||
) | ||
|
||
//go:embed "draft.template" | ||
var templateContents string | ||
|
||
func main() { | ||
inputs := actions.NewInputs() | ||
|
||
drafter := drafts.Drafter{Loader: drafts.RegistryBuildpackLoader{}} | ||
payload, err := drafter.CreatePayload(inputs, ".") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
scratchDir, err := ioutil.TempDir("", "drafts") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
err = drafter.BuildAndWriteReleaseToFileDraftFromTemplate( | ||
filepath.Join(scratchDir, "body"), templateContents, payload) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
name := payload.Release.Name | ||
if payload.PrimaryBuildpack.Info.Name != "" { | ||
name = fmt.Sprintf("%s %s", payload.PrimaryBuildpack.Info.Name, payload.Release.Name) | ||
} | ||
|
||
err = ioutil.WriteFile(filepath.Join(scratchDir, "name"), []byte(name), 0644) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
execution := effect.Execution{ | ||
Command: "gh", | ||
Args: []string{ | ||
"api", | ||
"--method", "PATCH", | ||
fmt.Sprintf("/repos/:owner/:repo/releases/%s", payload.Release.ID), | ||
"--field", fmt.Sprintf("tag_name=%s", payload.Release.Tag), | ||
"--field", fmt.Sprintf("name=@%s/name", scratchDir), | ||
"--field", fmt.Sprintf("body=@%s/body", scratchDir), | ||
}, | ||
} | ||
if _, dryRun := inputs["dry_run"]; dryRun { | ||
bits, err := ioutil.ReadFile(filepath.Join(scratchDir, "body")) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println("Title:", name) | ||
fmt.Println("Body:", string(bits)) | ||
fmt.Println("Would execute:", execution) | ||
} else { | ||
err = effect.NewExecutor().Execute(execution) | ||
if err != nil { | ||
panic(fmt.Errorf("unable to execute %s\n%w", execution, err)) | ||
} | ||
} | ||
} |
Oops, something went wrong.