From a4d9ca65a269e07d54b665f63260ddfbc8e9f1d4 Mon Sep 17 00:00:00 2001 From: Bohdan Shulha Date: Thu, 27 Jun 2024 10:40:55 +0200 Subject: [PATCH] chore: #2 add ci/cd Release-As: 0.0.1 --- .github/workflows/build.yml | 12 ++++++++ .github/workflows/release-please.yml | 44 ++++++++++++++++++++++++++++ cmd/ptah-agent/ptah-agent.go | 7 +---- 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..da5722d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,12 @@ +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + - run: go build -o ptah-agent-linux-x86_64 cmd/ptah-agent/ptah-agent.go diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..05a6472 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,44 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: go + - run: echo "release_created=${{ steps.release.outputs.release_created }}" >> "$GITHUB_OUTPUT" + - run: echo "tag_name=${{ steps.release.outputs.tag_name }}" >> "$GITHUB_OUTPUT" + + set-version-and-upload: + runs-on: ubuntu-latest + needs: release-please + if: ${{ needs.release-please.outputs.release_created }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + - run: | + go build -o ptah-agent-linux-x86_64-${{ needs.release-please.outputs.tag_name }}-bin \ + -ldflags "-X main.version=${{ needs.release-please.outputs.tag_name }}" \ + cmd/ptah-agent/ptah-agent.go + - uses: actions/upload-artifact@v4 + with: + name: ptah-agent-linux-x86_64 + path: ptah-agent-linux-x86_64 + - run: gh release upload "${{ needs.release-please.outputs.tag_name }}" ptah-agent-linux-x86_64-${{ needs.release-please.outputs.tag_name }}-bin + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/cmd/ptah-agent/ptah-agent.go b/cmd/ptah-agent/ptah-agent.go index f68a1a7..c9b9c9b 100644 --- a/cmd/ptah-agent/ptah-agent.go +++ b/cmd/ptah-agent/ptah-agent.go @@ -6,16 +6,11 @@ import ( "log" ) -// TODO: apply this on CI -// -// go build -o mybinary \ -// -ldflags "-X main.version=1.0.0" \ -// main.go var version string = "dev" func main() { baseUrl := "http://localhost:8000/api/_nodes/v1" - ptahToken := "8JKoOtkGpe6E7zRgGBtKXyROcJ52nmfOqd93MVanvs" + ptahToken := "aSpD6hq28mIUbdfP0lh6HgqGXVNQRv4SLwNCTHLwFh" agent := ptahAgent.New(version, baseUrl, ptahToken)