Skip to content

Commit

Permalink
chore: #2 add ci/cd
Browse files Browse the repository at this point in the history
Release-As: 0.0.1
  • Loading branch information
bohdan-shulha committed Jun 27, 2024
1 parent 6d37ab7 commit a4d9ca6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -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 }}
7 changes: 1 addition & 6 deletions cmd/ptah-agent/ptah-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a4d9ca6

Please sign in to comment.