-
Notifications
You must be signed in to change notification settings - Fork 1
feat: initial repository structure #1
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
.git/ | ||
.github/ | ||
Dockerfule | ||
chnsd | ||
README.md |
This file contains hidden or 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,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains hidden or 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,31 @@ | ||
name: Docker CI | ||
|
||
on: | ||
pull_request: | ||
branches: ['main'] | ||
paths: ['Dockerfile','cmd/**','docs/**','internal/**','go.*','.github/workflows/ci-docker.yml'] | ||
|
||
env: | ||
GHCR_IMAGE_NAME: ghcr.io/blinklabs-io/chnsd | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: qemu | ||
uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.GHCR_IMAGE_NAME }} | ||
- name: build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: false | ||
### TODO: test multiple platforms | ||
# platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains hidden or 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,16 @@ | ||
# The below is pulled from upstream and slightly modified | ||
# https://github.com/webiny/action-conventional-commits/blob/master/README.md#usage | ||
|
||
name: Conventional Commits | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Conventional Commits | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: webiny/[email protected] |
This file contains hidden or 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 @@ | ||
# This file was copied from the following URL and modified: | ||
# https://github.com/golangci/golangci-lint-action/blob/master/README.md#how-to-use | ||
|
||
name: golangci | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
permissions: | ||
contents: read | ||
pull-requests: read | ||
jobs: | ||
golangci: | ||
name: lint | ||
strategy: | ||
matrix: | ||
go-version: [1.18.x, 1.19.x] | ||
platform: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.50.1 # current version at time of commit | ||
# Optional: golangci-lint command line arguments. | ||
# args: --issues-exit-code=0 | ||
only-new-issues: true | ||
- name: go-test | ||
run: go test ./... |
This file contains hidden or 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,139 @@ | ||
name: publish | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
tags: | ||
- 'v*.*.*' | ||
|
||
concurrency: ${{ github.ref }} | ||
|
||
jobs: | ||
create-draft-release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
RELEASE_ID: ${{ steps.create-release.outputs.result }} | ||
steps: | ||
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" | ||
- uses: actions/github-script@v6 | ||
id: create-release | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
result-encoding: string | ||
script: | | ||
try { | ||
const response = await github.rest.repos.createRelease({ | ||
draft: true, | ||
generate_release_notes: true, | ||
name: process.env.RELEASE_TAG, | ||
owner: context.repo.owner, | ||
prerelease: false, | ||
repo: context.repo.repo, | ||
tag_name: process.env.RELEASE_TAG, | ||
}); | ||
|
||
return response.data.id; | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
|
||
build-binaries: | ||
strategy: | ||
matrix: | ||
os: [linux, darwin, freebsd, windows] | ||
arch: [amd64, arm64] | ||
runs-on: ubuntu-latest | ||
needs: [create-draft-release] | ||
steps: | ||
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
- name: Build binary | ||
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build | ||
- name: Upload release asset | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
_filename=chnsd-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }} | ||
if [[ ${{ matrix.os }} == windows ]]; then | ||
_filename=${_filename}.exe | ||
fi | ||
mv chnsd ${_filename} | ||
curl \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Content-Type: application/octet-stream" \ | ||
--data-binary @${_filename} \ | ||
https://uploads.github.com/repos/${{ github.repository_owner }}/chnsd/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=${_filename} | ||
|
||
build-images: | ||
runs-on: ubuntu-latest | ||
needs: [create-draft-release] | ||
steps: | ||
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" | ||
- uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: blinklabs | ||
password: ${{ secrets.DOCKER_PASSWORD }} # uses token | ||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
- id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
blinklabs/chnsd | ||
ghcr.io/${{ github.repository }} | ||
tags: | | ||
# Only version, no revision | ||
type=match,pattern=v(.*)-(.*),group=1 | ||
# branch | ||
type=ref,event=branch | ||
# semver | ||
type=semver,pattern={{version}} | ||
- name: Build images | ||
uses: docker/build-push-action@v3 | ||
with: | ||
outputs: "type=registry,push=true" | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
# Update Docker Hub from README | ||
- name: Docker Hub Description | ||
uses: peter-evans/dockerhub-description@v3 | ||
with: | ||
username: blinklabs | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
repository: blinklabs/chnsd | ||
readme-filepath: ./README.md | ||
short-description: "Snek is a tool for tailing the Cardano blockchain and emitting events" | ||
|
||
finalize-release: | ||
runs-on: ubuntu-latest | ||
needs: [create-draft-release, build-binaries, build-images] | ||
steps: | ||
- uses: actions/github-script@v6 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
try { | ||
await github.rest.repos.updateRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: ${{ needs.create-draft-release.outputs.RELEASE_ID }}, | ||
draft: false, | ||
}); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*.dll | ||
*.so | ||
*.dylib | ||
/chnsd | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains hidden or 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,9 @@ | ||
FROM cgr.dev/chainguard/golang:1.19 AS build | ||
|
||
WORKDIR /code | ||
COPY . . | ||
RUN make build | ||
|
||
FROM cgr.dev/chainguard/glibc-dynamic AS chnsd | ||
COPY --from=build /code/chnsd /usr/local/bin/ | ||
ENTRYPOINT ["/usr/local/bin/chnsd"] |
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
# Determine root directory | ||
ROOT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
# Gather all .go files for use in dependencies below | ||
GO_FILES=$(shell find $(ROOT_DIR) -name '*.go') | ||
|
||
# Gather list of expected binaries | ||
BINARIES=$(shell cd $(ROOT_DIR)/cmd && ls -1 | grep -v ^common) | ||
|
||
# Extract Go module name from go.mod | ||
GOMODULE=$(shell grep ^module $(ROOT_DIR)/go.mod | awk '{ print $$2 }') | ||
|
||
# Set version strings based on git tag and current ref | ||
GO_LDFLAGS=-ldflags "-s -w" | ||
|
||
.PHONY: build mod-tidy clean test | ||
|
||
# Alias for building program binary | ||
build: $(BINARIES) | ||
|
||
mod-tidy: | ||
# Needed to fetch new dependencies and add them to go.mod | ||
go mod tidy | ||
|
||
clean: | ||
rm -f $(BINARIES) | ||
|
||
test: mod-tidy | ||
go test -v ./... | ||
|
||
# Build our program binaries | ||
# Depends on GO_FILES to determine when rebuild is needed | ||
$(BINARIES): mod-tidy $(GO_FILES) | ||
go build \ | ||
$(GO_LDFLAGS) \ | ||
-o $(@) \ | ||
./cmd/$(@) |
This file contains hidden or 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,9 @@ | ||
// Copyright 2023 Blink Labs, LLC. | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
package main | ||
|
||
func main() {} |
This file contains hidden or 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,3 @@ | ||
module github.com/blinklabs-io/chnsd | ||
|
||
go 1.19 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.