From a2aff2a9c6ec3b71d9393e3d328234ab9dc6bee1 Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Sun, 4 Sep 2022 21:58:38 +0200 Subject: [PATCH] Add autorelease workflow Signed-off-by: Dominik Schulz --- .github/dependabot.yml | 9 +--- .github/workflows/autorelease.yml | 69 +++++++++++++++++++++++++++++++ .github/workflows/build.yml | 2 +- helpers/changelog/main.go | 30 ++++++++++++++ 4 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/autorelease.yml create mode 100644 helpers/changelog/main.go diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5b36a0c..afaab80 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,12 +4,5 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" - open-pull-requests-limit: 5 - - - - package-ecosystem: "gomod" - directory: "/" - schedule: - interval: "daily" + interval: "weekly" open-pull-requests-limit: 5 diff --git a/.github/workflows/autorelease.yml b/.github/workflows/autorelease.yml new file mode 100644 index 0000000..5f4e5c9 --- /dev/null +++ b/.github/workflows/autorelease.yml @@ -0,0 +1,69 @@ +# This is a basic workflow to help you get started with Actions + +name: release gopass-hibp + +# Controls when the action will run. +on: + # Triggers the workflow on tags starting with v, i.e. release tags + push: + tags: + - 'v*' + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - + name: Import GPG signing key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + - + name: Debug + run: | + echo "GPG ---------------------" + echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}" + echo "keyid: ${{ steps.import_gpg.outputs.keyid }}" + echo "name: ${{ steps.import_gpg.outputs.name }}" + echo "email: ${{ steps.import_gpg.outputs.email }}" + echo "Go env ------------------" + pwd + echo ${HOME} + echo ${GITHUB_WORKSPACE} + echo ${GOPATH} + echo ${GOROOT} + env + - + name: Generate release-notes + run: | + go run helpers/changelog/main.go >../RELEASE_NOTES + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3.1.0 + with: + version: latest + args: release --rm-dist --release-notes=../RELEASE_NOTES + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GOPATH: /home/runner/go + - + name: "Upload deb files to apt hosting" + run: | + for D in dist/*.deb; do + curl -H"X-Filename: ${D}" -H"X-Apikey: ${APIKEY}" -XPOST --data-binary @$D https://packages.gopass.pw/repos/gopass/upload + done + env: + APIKEY: ${{ secrets.APT_APIKEY }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ce338a..192b3b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build gopass +name: Build gopass-hibp on: push: diff --git a/helpers/changelog/main.go b/helpers/changelog/main.go new file mode 100644 index 0000000..99283fc --- /dev/null +++ b/helpers/changelog/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strings" +) + +func main() { + fh, err := os.Open("CHANGELOG.md") + if err != nil { + panic(err) + } + defer fh.Close() + + s := bufio.NewScanner(fh) + var in bool + for s.Scan() { + line := s.Text() + if strings.HasPrefix(line, "## ") { + if in { + break + } + in = true + } + + fmt.Println(line) + } +}