name: Build Golang packages on: push: branches: - "**" tags: - "v*.*.*" pull_request: branches: - "main" jobs: release: runs-on: ubuntu-docker steps: - name: Check out repository code uses: actions/checkout@v4 - name: Setup go uses: actions/setup-go@v4 with: go-version: '>=1.22' cache: false - name: release-build-linux-amd64 run: GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-linux-amd64 - name: release-build-linux-arm64 run: GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-linux-arm64 - name: release-build-windows-amd64 run: GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-windows-amd64.exe - name: release-build-windows-arm64 run: GOOS=windows GOARCH=arm64 go build -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-windows-arm64.exe - name: release-build-darwin-amd64 run: GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-darwin-amd64 - name: release-build-darwin-arm64 run: GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-darwin-arm64 - name: Use Go Action id: use-go-action uses: https://gitea.com/actions/release-action with: files: |- bin/** api_key: '${{secrets.CI_PACKAGES_RW}}' # - name: Create Release # id: create_release # env: # GITEA_TOKEN: ${{ secrets.CI_PACKAGES_RW }} # run: | # RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" -H "Authorization: token ${GITEA_TOKEN}" \ # -d '{ # "tag_name": "${{ github.ref_name }}", # "target_commitish": "main", # "name": "Release ${{ github.ref_name }}", # "body": "Description of the release", # "draft": false, # "prerelease": false # }' \ # "https://git.hollander.online/api/v1/repos/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}/releases") # echo "::set-output name=id::$(echo $RESPONSE | jq .id)" # - name: Upload Assets # env: # GITEA_TOKEN: ${{ secrets.CI_PACKAGES_RW }} # run: | # for BINARY in bin/*; do # curl -X POST -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/octet-stream" --data-binary "@$BINARY" \ # "https://git.hollander.online/api/v1/repos/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}/releases/${{ steps.create_release.outputs.id }}/assets?name=$(basename $BINARY)" # done