Skip to content

Commit

Permalink
Merge pull request #8 from numary/feat/add_goReleaser
Browse files Browse the repository at this point in the history
feat(CI): Add GoReleaser
  • Loading branch information
flemzord authored Jul 5, 2021
2 parents 648f4ca + e216557 commit 92ed340
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 68 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on:
push:
branches:
- main
name: Main
jobs:
oas:
name: 'OAS Readme'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: readmeio/github-readme-sync@v2
with:
readme-oas-key: ${{ secrets.README_OAS_KEY }}
oas-file-path: './spec/http.yml'
api-version: 'v1.0.0'
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- uses: actions/checkout@v2
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: get deps
run: go get
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: build --parallelism 4 --rm-dist --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: numary-preprod-ecr
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
16 changes: 0 additions & 16 deletions .github/workflows/oas-readme.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/pr_open.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Pull Request - Open
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
Test:
name: 'Test'
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- uses: actions/checkout@v2
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: get deps
run: go get
- name: run tests
run: go test -v -coverpkg=./... -coverprofile=coverage.out ./...
Lint:
name: 'Lint'
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- uses: actions/checkout@v2
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: get deps
run: go get
- name: run vet
run: go vet .
45 changes: 18 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,43 @@
name: release
on:
release:
types:
- created
types: [created]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: amd64
cc: gcc

env:
GOOS: linux
GOARCH: ${{ matrix.arch }}

steps:
- uses: actions/setup-go@v2
with:
go-version: '1.16'

- uses: actions/checkout@v2

- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://altitude:${TOKEN}@github.com".insteadOf "https://github.com"

- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: get deps
run: go get

- id: get-release
uses: bruceadams/get-release@v1.2.2
env:
GITHUB_TOKEN: ${{ github.token }}

- name: build
run: |
CGO_ENABLED=1 go build -o numary
tar -czvf numary-${{ steps.get-release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}.tar.gz numary
- name: upload release
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
upload_url: ${{ steps.get-release.outputs.upload_url }}
asset_path: numary-${{ steps.get-release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}.tar.gz
asset_name: numary-${{ steps.get-release.outputs.tag_name }}-${{ env.GOOS }}-${{ env.GOARCH }}.tar.gz
asset_content_type: application/gzip
version: latest
args: release --parallelism 2 --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
numary
coverage.out
coverage.out
/dist/
23 changes: 23 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
before:
hooks:
- go build -o numary
builds:
- env:
- CGO_ENABLED=1
goos:
- linux
binary: numary
archives:
- replacements:
linux: Linux
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:latest

ADD numary /usr/local/bin/numary
ADD dist/ledger_linux_amd64/numary /usr/local/bin/numary

EXPOSE 3068

CMD ["numary", "server", "start"]
CMD ["numary", "server", "start"]

0 comments on commit 92ed340

Please sign in to comment.