Skip to content

Commit

Permalink
Build silta cli binary on release creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jancis committed Feb 10, 2022
1 parent 16781f5 commit 8a406d5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 15 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build silta cli binary on release creation

on:
release:
types: [created]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
tests-matrix:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: [amd64]
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.6
- name: Run tests
run: go test -v ./tests
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
needs: tests-matrix
strategy:
matrix:
goos: [linux]
goarch: [amd64]
steps:
- uses: actions/checkout@v2
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://go.dev/dl/go1.17.6.${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz"
binary_name: "silta"
ldflags: "-X github.com/wunderio/silta-cli/internal/common.Version=${{ steps.vars.outputs.tag }}"
6 changes: 3 additions & 3 deletions tests/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func TestBuild(t *testing.T) {
wd, _ := os.Getwd()
os.Chdir("..")

make := exec.Command("make", "build")
err := make.Run()
out, err := exec.Command("bash", "-c", "make build").CombinedOutput()
fmt.Printf("Output: %s\n", out)
if err != nil {
fmt.Printf("could not make binary for %s: %v", cliBinaryName, err)
fmt.Printf("Could not make binary for %s: %v", cliBinaryName, err)
os.Exit(1)
}

Expand Down
12 changes: 0 additions & 12 deletions tests/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ func TestImageUrlCmd(t *testing.T) {
testString = `foo.bar/silta/baz-nginx:qux`
CliExecTest(t, command, environment, testString, true)

// Checksum calculation test
command = "ci image url --image-repo-host 'foo.bar' --image-repo-project 'silta' --namespace 'baz' --image-identifier 'nginx' --dockerfile 'tests/nginx.Dockerfile'"
environment = []string{}
testString = `foo.bar/silta/baz-nginx:6d2304e6e2bfe938b70f059944fc567bfdd37903`
CliExecTest(t, command, environment, testString, true)

// Change dir back to previous
os.Chdir(wd)
}
Expand All @@ -129,12 +123,6 @@ func TestImageBuildCmd(t *testing.T) {
testString = `docker push 'foo.bar/silta/baz-nginx:qux'`
CliExecTest(t, command, environment, testString, false)

// // Checksum calculation test
command = "ci image build --image-repo-host 'foo.bar' --image-repo-project 'silta' --namespace 'baz' --image-identifier 'nginx' --dockerfile 'tests/nginx.Dockerfile' --debug"
environment = []string{}
testString = `docker build --tag 'foo.bar/silta/baz-nginx:6d2304e6e2bfe938b70f059944fc567bfdd37903' -f 'tests/nginx.Dockerfile' /tmp/empty`
CliExecTest(t, command, environment, testString, false)

// Change dir back to previous
os.Chdir(wd)
}

0 comments on commit 8a406d5

Please sign in to comment.