Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Improvements to the code base #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
83 changes: 83 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and Generate Release

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Get version from version file
id: get_version
run:
echo "VERSION=$(cat ./version)" >> "$GITHUB_OUTPUT"

- name: Previous version
id: prev_version
run: |
git fetch --tags
echo "PREV_VERSION=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT"

- name: Check if version is already tagged
id: check_tag
run: |
if git rev-parse "${{ steps.get_version.outputs.VERSION }}-ada" >/dev/null 2>&1; then
echo "TAGGED=true" >> "$GITHUB_OUTPUT"
else
echo "TAGGED=false" >> "$GITHUB_OUTPUT"
fi

- name: Get commit messages between tags
id: commit-msgs
if: steps.check_tag.outputs.TAGGED == 'false'
run: |
git fetch --tags
git log --pretty=format:%h\ %s --no-decorate \
${{ steps.prev_version.outputs.PREV_VERSION }}..HEAD --oneline > commit-messages.txt
echo "COMMIT_MSGS=$(cat commit-messages.txt)" >> "$GITHUB_OUTPUT"

- name: Build
if: steps.check_tag.outputs.TAGGED == 'false'
run: go build \
-v --ldflags "-X 'github.com/AdaSupport/ejson-kms/cli.version=${{ steps.get_version.outputs.VERSION }}-ada' \
-X 'github.com/AdaSupport/ejson-kms/cli.sha1=$GITHUB_SHA'" \
-o ./ada-ejson-kms

- name: Generate Release
id: create_release
if: steps.check_tag.outputs.TAGGED == 'false'
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ steps.get_version.outputs.VERSION }}-ada"
release_name: "Release ${{ steps.get_version.outputs.VERSION }}-ada"
draft: false
prerelease: false
body: |
${{ steps.commit-msgs.outputs.COMMIT_MSGS }}

- name: Upload Artifact
if: steps.check_tag.outputs.TAGGED == 'false'
uses: actions/upload-artifact@v2
with:
name: ada-ejson-kms
path: ./ada-ejson-kms

- name: Output sha256
if: steps.check_tag.outputs.TAGGED == 'false'
id: sha256
run: |
echo "SHA256=$(shasum -a 256 ada-ejson-kms | awk '{print $1}')"
20 changes: 20 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Go Test

on:
- push

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22

- name: Test
run: go test -v ./...
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.4.0
Loading