Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatic release to GitHub #279

Merged
merged 9 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build-artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: build dev artifact

on:
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- run: make dev
- uses: actions/upload-artifact@v3
with:
name: linux_x64
path: ${{ github.workspace }}/bin/noisetorch
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: release

on:
push:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: Build release artifact
run: |
make release
git describe --tags > version.txt
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ github.workspace }}/bin/NoiseTorch_x64_*.tgz
${{ github.workspace }}/bin/NoiseTorch_x64_*.tgz.sig
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
UPDATE_URL=https://noisetorch.epicgamer.org
UPDATE_PUBKEY=3mL+rBi4yBZ1wGimQ/oSQCjxELzgTh+673H4JdzQBOk=
UPDATE_URL=
UPDATE_PUBKEY=
VERSION := $(shell git describe --tags)

dev: rnnoise
Expand All @@ -18,13 +18,11 @@ release: rnnoise

mkdir -p tmp/.local/bin/
go generate
CGO_ENABLED=0 GOOS=linux go build -trimpath -tags release -a -ldflags '-s -w -extldflags "-static" -X main.version=${VERSION} -X main.distribution=official -X main.updateURL=${UPDATE_URL} -X main.publicKeyString=${UPDATE_PUBKEY}' .
upx noisetorch
CGO_ENABLED=0 GOOS=linux go build -trimpath -tags release -a -ldflags '-s -w -extldflags "-static" -X main.version=${VERSION} -X main.distribution=official' .
mv noisetorch tmp/.local/bin/
cd tmp/; \
tar cvzf ../bin/NoiseTorch_x64.tgz .
tar cvzf ../bin/NoiseTorch_x64_${VERSION}.tgz .
rm -rf tmp/
go run scripts/signer.go -s
git describe --tags > bin/version.txt
go run scripts/signer.go -s -f bin/NoiseTorch_x64_${VERSION}.tgz
rnnoise:
$(MAKE) -C c/ladspa
19 changes: 13 additions & 6 deletions scripts/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ func main() {
var publicKeyString string
flag.StringVar(&publicKeyString, "k", "", "Public key to verify against (runs verifier if set)")

var artifactFile string
flag.StringVar(&artifactFile, "f", "", "Artifact file name and path that should be signed")

flag.Parse()

signatureFile := artifactFile + ".sig"

if doGenerate {
generateKeypair()
os.Exit(0)
Expand All @@ -38,10 +43,10 @@ func main() {
os.Exit(0)
}

if doSign {
if doSign && artifactFile != "" {
_, priv := loadKeys()

file, err := ioutil.ReadFile("bin/NoiseTorch_x64.tgz")
file, err := ioutil.ReadFile(artifactFile)
if err != nil {
panic(err)
}
Expand All @@ -50,24 +55,26 @@ func main() {
if err != nil {
panic(err)
}
if err := ioutil.WriteFile("bin/NoiseTorch_x64.tgz.sig", sig, 0644); err != nil {

err = ioutil.WriteFile(signatureFile, sig, 0640)
if err != nil {
panic(err)
}
os.Exit(0)
}

if publicKeyString != "" {
if publicKeyString != "" && artifactFile != "" && signatureFile != "" {
pub, err := base64.StdEncoding.DecodeString(publicKeyString)
if err != nil {
panic(err)
}

file, err := ioutil.ReadFile("bin/NoiseTorch_x64.tgz")
file, err := ioutil.ReadFile(artifactFile)
if err != nil {
panic(err)
}

sig, err := ioutil.ReadFile("bin/NoiseTorch_x64.tgz.sig")
sig, err := ioutil.ReadFile(signatureFile)
if err != nil {
panic(err)
}
Expand Down