diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..c494ed3 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,93 @@ +name: CI +run-name: ${{ gitea.actor }} running CI +on: [push] + +jobs: + test: + runs-on: ubuntu-22.04 + env: + RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.24.0' # The Go version to download (if necessary) and use. + - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: | + go.mod + go.sum + - name: Echo hash + run: echo ${{ steps.hash-go.outputs.hash }} + - name: Cache go + id: cache-go + uses: https://github.com/actions/cache@v3 # Action cache + with: # specify with your GOMODCACHE and GOCACHE + path: |- + /root/go/pkg/mod + /root/.cache/go-build + key: go_cache-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} + - run: go version + + # unit and integration tests, coverage + - run: go test ./... -coverprofile cover.out + - run: go tool cover -html=cover.out -o cover.html + + - uses: actions/upload-artifact@v3 + with: + name: coverage.html + path: ./cover.html + + build: + needs: test + runs-on: ubuntu-22.04 + env: + RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.24.0' # The Go version to download (if necessary) and use. + - uses: https://gitea.com/actions/go-hashfiles@v0.0.1 + id: hash-go + with: + patterns: | + go.mod + go.sum + - name: Echo hash + run: echo ${{ steps.hash-go.outputs.hash }} + - name: Cache go + id: cache-go + uses: https://github.com/actions/cache@v3 # Action cache + with: # specify with your GOMODCACHE and GOCACHE + path: |- + /root/go/pkg/mod + /root/.cache/go-build + key: go_cache-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} + + # build all binaries + - name: build binaries + run: | + GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o charmite_darwin_amd64 . + GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o charmite_darwin_arm64 . + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o charmite_linux_amd64 . + GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o charmite_windows_amd64.exe . + + # upload + - name: Upload artifacts to Gitea package repository + env: + GITEA_API_URL: https://code.ppl.town/api + GITEA_TOKEN: ${{ secrets.PACKAGE_API_KEY }} + REPOSITORY: charmite + VERSION: 0.0.1 + run: | + curl -D- -s -X PUT "$GITEA_API_URL/packages/$REPOSITORY/generic/charmite/$VERSION/charmite_darwin_amd64" \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @charmite_darwin_amd64 + \ No newline at end of file