name: Build and Release Ody Agent on: push: tags: - 'v*' workflow_dispatch: inputs: version: description: 'Version tag (e.g. v1.0.0)' required: false default: 'dev' jobs: build: runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - name: Set up Go uses: https://github.com/actions/setup-go@v5 with: go-version: '1.22' - name: Set version id: version run: | if [ "${{ github.event_name }}" = "push" ]; then echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT else echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT fi - name: Build all platforms run: | mkdir -p dist cd ody-agent GOOS=windows GOARCH=amd64 CGO_ENABLED=0 \ go build -ldflags "-s -w -H=windowsgui -X main.defaultServer=https://425.today" \ -o ../dist/ody-agent-win.exe . GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 \ go build -ldflags "-s -w -X main.defaultServer=https://425.today" \ -o ../dist/ody-agent-mac-arm64 . GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 \ go build -ldflags "-s -w -X main.defaultServer=https://425.today" \ -o ../dist/ody-agent-mac-amd64 . GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ go build -ldflags "-s -w -X main.defaultServer=https://425.today" \ -o ../dist/ody-agent-linux . ls -lh ../dist/ - name: Create release and upload assets run: | VERSION="${{ steps.version.outputs.VERSION }}" echo "Publishing release $VERSION" # Create the release (may already exist from manual tag push) RELEASE=$(curl -sf -X POST "https://git.wellspr.ing/api/v1/repos/wellspring/ody-agent/releases" \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$VERSION\",\"name\":\"Ody Agent $VERSION\",\"body\":\"### Ody Agent $VERSION\n\nDesktop agent for WellSpr.ing / NNN.today merchants.\n\n| Platform | File |\n|---|---|\n| Windows | \`ody-agent-win.exe\` |\n| macOS Apple Silicon | \`ody-agent-mac-arm64\` |\n| macOS Intel | \`ody-agent-mac-amd64\` |\n| Linux | \`ody-agent-linux\` |\",\"draft\":false,\"prerelease\":false}" \ || curl -sf "https://git.wellspr.ing/api/v1/repos/wellspring/ody-agent/releases/tags/$VERSION" \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}") RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") echo "Release ID: $RELEASE_ID" for f in dist/*; do FNAME=$(basename "$f") echo "Uploading $FNAME..." curl -sf -X POST \ "https://git.wellspr.ing/api/v1/repos/wellspring/ody-agent/releases/$RELEASE_ID/assets?name=$FNAME" \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ -H "Content-Type: application/octet-stream" \ --data-binary "@$f" echo " uploaded." done echo "Release complete: https://git.wellspr.ing/wellspring/ody-agent/releases/tag/$VERSION"