Skip to content

Commit

Permalink
Merge pull request #79 from balena-io/ab77/operational
Browse files Browse the repository at this point in the history
build with Flowzone
  • Loading branch information
flowzone-app[bot] authored May 8, 2023
2 parents ac4eca4 + 32a0c41 commit 361356e
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 59 deletions.
39 changes: 0 additions & 39 deletions .circleci/config.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: build and draft GitHub release
# https://github.com/product-os/flowzone/tree/master/.github/actions
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true
variables:
description: "JSON stringified object containing all the variables from the calling workflow"
required: true

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
using: "composite"
steps:
- shell: bash
run: |
docker compose -f docker-compose.test.yml run sut 'make -j $(nproc) dep release'
# expecting five (5) of each
binaries="$(find build -type f -name '*.tar.gz' | wc -l)"
checksums="$(find build -type f -name '*.sha256' | wc -l)"
if [[ $binaries -lt $checksums ]] || [[ $binaries -lt 5 ]]; then
find build -type f
false
fi
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: gh-release-${{ github.event.pull_request.head.sha || github.event.head_commit.id }}
path: |
build/*.sha256
build/*.tar.gz
retention-days: 1
28 changes: 28 additions & 0 deletions .github/workflows/flowzone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Flowzone

on:
pull_request:
types: [opened, synchronize, closed]
branches: [main, master]
pull_request_target:
types: [opened, synchronize, closed]
branches: [main, master]

jobs:
flowzone:
name: Flowzone
uses: product-os/flowzone/.github/workflows/flowzone.yml@master
# prevent duplicate workflow executions for pull_request and pull_request_target
if: |
(
github.event.pull_request.head.repo.full_name == github.repository &&
github.event_name == 'pull_request'
) || (
github.event.pull_request.head.repo.full_name != github.repository &&
github.event_name == 'pull_request_target'
)
secrets: inherit
with:
repo_config: true
repo_description: "sshproxy is a simple ssh server library exposing an even simpler API"
docker_images: ""
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ vendor/
bin/*
build/*
release/*

## Other
.DS_Store
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM golang:1.18.0
20 changes: 3 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ USERNAME ?= balena-io
PROJECT ?= sshproxy
EXECUTABLE ?= sshproxy
VERSION ?= $(shell git describe --abbrev=0 --tags --exact-match 2>/dev/null || git describe)
BUILD_PLATFORMS ?= darwin/amd64 linux/386 linux/arm linux/arm64 linux/amd64
# https://github.com/golang/go/blob/master/src/go/build/syslist.go
BUILD_PLATFORMS ?= darwin/amd64 darwin/arm64 linux/arm linux/arm64 linux/amd64
SHASUM ?= sha256sum

all: bin/$(EXECUTABLE)
Expand Down Expand Up @@ -32,21 +33,6 @@ test: test-dep
release: $(addsuffix .tar.gz,$(addprefix build/$(EXECUTABLE)-$(VERSION)_,$(subst /,_,$(BUILD_PLATFORMS))))
release: $(addsuffix .tar.gz.sha256,$(addprefix build/$(EXECUTABLE)-$(VERSION)_,$(subst /,_,$(BUILD_PLATFORMS))))

upload-dep:
go install github.com/aktau/github-release@latest

upload: lint test upload-dep
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is undefined)
endif
git describe --exact-match --tags >/dev/null

git log --format='* %s' --grep='change-type:' --regexp-ignore-case $(shell git describe --tag --abbrev=0 $(VERSION)^)...$(VERSION) | \
github-release release -u $(USERNAME) -r $(PROJECT) -t $(VERSION) -n $(VERSION) -d - || true
$(foreach FILE, $(addsuffix .tar.gz,$(addprefix build/$(EXECUTABLE)-$(VERSION)_,$(subst /,_,$(BUILD_PLATFORMS)))), \
github-release upload -u $(USERNAME) -r $(PROJECT) -t $(VERSION) -n $(notdir $(FILE)) -f $(FILE) && \
github-release upload -u $(USERNAME) -r $(PROJECT) -t $(VERSION) -n $(notdir $(addsuffix .sha256,$(FILE))) -f $(addsuffix .sha256,$(FILE)) ;)

clean:
rm -vrf bin/* build/*

Expand All @@ -63,4 +49,4 @@ build/$(EXECUTABLE)-$(VERSION)_%.tar.gz: build/%/$(EXECUTABLE)
%.sha256: %
cd $(dir $<) && $(SHASUM) $(notdir $<) > $(addsuffix .sha256,$(notdir $<))

.PHONY: dep lint-dep lint test-dep test release upload-dep upload clean
.PHONY: dep lint-dep lint test-dep test release clean
17 changes: 17 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
version: "2.4"

services:
sut:
image: golang:1.18.0
volumes:
- .:/go/src/github.com/balena-io/sshproxy
working_dir: /go/src/github.com/balena-io/sshproxy
entrypoint:
- /bin/bash
- "-c"
command:
- |
set -axe
make -j $$(nproc) clean dep lint test
3 changes: 0 additions & 3 deletions package-lock.json

This file was deleted.

2 changes: 2 additions & 0 deletions repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
type: docker

0 comments on commit 361356e

Please sign in to comment.