diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..62082db --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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}')" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..c74fcbb --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 ./... diff --git a/version b/version new file mode 100644 index 0000000..64b5ae3 --- /dev/null +++ b/version @@ -0,0 +1 @@ +4.4.0 \ No newline at end of file