forked from direnv/direnv
-
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.
- Loading branch information
Showing
3 changed files
with
139 additions
and
0 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,37 @@ | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
# TODO: also publish the dist | ||
name: Create Release | ||
|
||
jobs: | ||
build: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.13.6 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13.6 | ||
- name: Checkout code | ||
uses: actions/checkout@master | ||
- name: Get release notes | ||
id: release-notes | ||
run: | | ||
go run ./script/issue-command/main.go set-output \ | ||
--name=body \ | ||
"$(go run ./script/release-changelog/main.go)" | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: "${{ steps.release-notes.outputs.body }}" | ||
draft: true | ||
prerelease: false |
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,56 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func escapeData(data string) string { | ||
data = strings.ReplaceAll(data, "%", "%25") | ||
data = strings.ReplaceAll(data, "\r", "%0D") | ||
data = strings.ReplaceAll(data, "\n", "%0A") | ||
return data | ||
} | ||
|
||
func escapeProperty(prop string) string { | ||
prop = escapeData(prop) | ||
prop = strings.ReplaceAll(prop, ":", "%3A") | ||
prop = strings.ReplaceAll(prop, ",", "%2C") | ||
return prop | ||
} | ||
|
||
// Go implementation of | ||
// https://github.com/actions/toolkit/blob/master/packages/core/src/command.ts | ||
func main() { | ||
var remain []string | ||
var props []string | ||
|
||
for _, arg := range os.Args[1:] { | ||
if arg == "--" { | ||
continue | ||
} | ||
if strings.HasPrefix(arg, "--") { | ||
kv := strings.SplitN(arg[2:], "=", 2) | ||
if len(kv) != 2 { | ||
panic(fmt.Sprintf("expected %s to be of form --key=value", arg[2:])) | ||
} | ||
props = append(props, fmt.Sprintf("%s=%s", kv[0], escapeProperty(kv[1]))) | ||
} else { | ||
remain = append(remain, arg) | ||
} | ||
} | ||
|
||
if len(remain) != 2 { | ||
panic(fmt.Sprintf("expected 2 remaining arguments, go %v", remain)) | ||
} | ||
|
||
cmd := remain[0] | ||
msg := escapeData(remain[1]) | ||
var propStr string | ||
if len(props) > 0 { | ||
propStr = " " + strings.Join(props, ",") | ||
} | ||
|
||
fmt.Printf("::%s%s::%s", cmd, propStr, msg) | ||
} |
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,46 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func run() error { | ||
headers := 0 | ||
|
||
f, err := os.Open("CHANGELOG.md") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
r := bufio.NewReader(f) | ||
|
||
prev, err := r.ReadString('\n') | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for { | ||
line, err := r.ReadString('\n') | ||
if err != nil { | ||
return err | ||
} | ||
if strings.HasPrefix(line, "======") { | ||
headers++ | ||
} | ||
if headers > 1 { | ||
return nil | ||
} | ||
|
||
os.Stdout.WriteString(prev) | ||
prev = line | ||
} | ||
} | ||
|
||
func main() { | ||
err := run() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |