b4e4982876
- Adjusted formatting in XML response strings for consistency in device_extended_test.go and device_security_test.go. - Improved readability by aligning XML declaration and body content. - Updated mock server responses to ensure proper handling of various ONVIF operations. Enhance device security and storage handling - Refactored struct field declarations in device_security.go and device_storage_test.go for improved clarity. - Ensured consistent formatting across struct definitions and XML tags. Standardize whitespace and formatting across multiple files - Removed unnecessary blank lines and adjusted indentation in discovery, imaging, media, and PTZ server files. - Improved overall code readability and maintainability by ensuring consistent formatting. Update example applications for better readability - Cleaned up whitespace in example applications to enhance code clarity. - Ensured consistent formatting in main.go files across various examples. Refactor server and SOAP handler code for consistency - Standardized struct field declarations and XML tag formatting in server and SOAP handler files. - Improved readability by aligning struct fields and ensuring consistent use of whitespace. General code cleanup and formatting adjustments - Applied consistent formatting across various files, including types.go and test files. - Enhanced readability by aligning struct fields and removing unnecessary blank lines.
268 lines
9.1 KiB
YAML
268 lines
9.1 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Release Binaries
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
# Linux
|
|
- goos: linux
|
|
goarch: amd64
|
|
- goos: linux
|
|
goarch: arm64
|
|
- goos: linux
|
|
goarch: arm
|
|
goarm: 7
|
|
|
|
# Windows
|
|
- goos: windows
|
|
goarch: amd64
|
|
- goos: windows
|
|
goarch: arm64
|
|
|
|
# macOS
|
|
- goos: darwin
|
|
goarch: amd64
|
|
- goos: darwin
|
|
goarch: arm64
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@0a12ed9d6470c3512128ab8f076f97fbbff3da52 # v5.0.1
|
|
with:
|
|
go-version: '1.21'
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: |
|
|
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build binaries
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
GOARM: ${{ matrix.goarm }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.VERSION }}
|
|
LDFLAGS="-s -w -X main.Version=${VERSION} -X main.Commit=${{ steps.version.outputs.SHORT_SHA }}"
|
|
|
|
# Set file extension for Windows
|
|
EXT=""
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
|
EXT=".exe"
|
|
fi
|
|
|
|
# Build all CLI tools
|
|
mkdir -p dist
|
|
|
|
echo "Building onvif-cli..."
|
|
go build -ldflags="${LDFLAGS}" -o "dist/onvif-cli-${{ matrix.goos }}-${{ matrix.goarch }}${EXT}" ./cmd/onvif-cli
|
|
|
|
echo "Building onvif-quick..."
|
|
go build -ldflags="${LDFLAGS}" -o "dist/onvif-quick-${{ matrix.goos }}-${{ matrix.goarch }}${EXT}" ./cmd/onvif-quick
|
|
|
|
echo "Building onvif-server..."
|
|
go build -ldflags="${LDFLAGS}" -o "dist/onvif-server-${{ matrix.goos }}-${{ matrix.goarch }}${EXT}" ./cmd/onvif-server
|
|
|
|
echo "Building onvif-diagnostics..."
|
|
go build -ldflags="${LDFLAGS}" -o "dist/onvif-diagnostics-${{ matrix.goos }}-${{ matrix.goarch }}${EXT}" ./cmd/onvif-diagnostics
|
|
|
|
- name: Create archive
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.VERSION }}
|
|
PLATFORM="${{ matrix.goos }}-${{ matrix.goarch }}"
|
|
ARCHIVE_NAME="onvif-go-${VERSION}-${PLATFORM}"
|
|
|
|
mkdir -p releases staging
|
|
|
|
# Copy binaries with clean names (without platform suffix)
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
|
cp dist/onvif-cli-${{ matrix.goos }}-${{ matrix.goarch }}.exe staging/onvif-cli.exe
|
|
cp dist/onvif-quick-${{ matrix.goos }}-${{ matrix.goarch }}.exe staging/onvif-quick.exe
|
|
cp dist/onvif-server-${{ matrix.goos }}-${{ matrix.goarch }}.exe staging/onvif-server.exe
|
|
cp dist/onvif-diagnostics-${{ matrix.goos }}-${{ matrix.goarch }}.exe staging/onvif-diagnostics.exe
|
|
else
|
|
cp dist/onvif-cli-${{ matrix.goos }}-${{ matrix.goarch }} staging/onvif-cli
|
|
cp dist/onvif-quick-${{ matrix.goos }}-${{ matrix.goarch }} staging/onvif-quick
|
|
cp dist/onvif-server-${{ matrix.goos }}-${{ matrix.goarch }} staging/onvif-server
|
|
cp dist/onvif-diagnostics-${{ matrix.goos }}-${{ matrix.goarch }} staging/onvif-diagnostics
|
|
fi
|
|
|
|
# Copy documentation
|
|
cp README.md LICENSE staging/
|
|
|
|
# Create archive from staging directory
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
|
cd staging
|
|
zip -r "../releases/${ARCHIVE_NAME}.zip" .
|
|
cd ..
|
|
else
|
|
cd staging
|
|
tar czf "../releases/${ARCHIVE_NAME}.tar.gz" .
|
|
cd ..
|
|
fi
|
|
|
|
- name: Generate checksums
|
|
run: |
|
|
cd releases
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
sha256sum * > checksums-${{ matrix.goos }}-${{ matrix.goarch }}.txt
|
|
else
|
|
shasum -a 256 * > checksums-${{ matrix.goos }}-${{ matrix.goarch }}.txt
|
|
fi
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: releases/*
|
|
retention-days: 5
|
|
|
|
release:
|
|
name: Create GitHub Release
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
|
with:
|
|
path: all-releases
|
|
pattern: release-*
|
|
merge-multiple: true
|
|
|
|
- name: Generate combined checksums
|
|
run: |
|
|
cd all-releases
|
|
# Combine all checksum files
|
|
cat checksums-*.txt > checksums.txt
|
|
# Remove individual checksum files
|
|
rm checksums-*.txt
|
|
|
|
- name: Get version and changelog
|
|
id: version
|
|
run: |
|
|
VERSION=${GITHUB_REF#refs/tags/}
|
|
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
# Generate changelog from commits since last tag
|
|
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
if [ -n "$PREV_TAG" ]; then
|
|
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
|
|
git log --pretty=format:"- %s (%h)" ${PREV_TAG}..HEAD >> $GITHUB_OUTPUT
|
|
echo "" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
|
|
with:
|
|
files: all-releases/*
|
|
draft: true
|
|
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
|
|
generate_release_notes: true
|
|
fail_on_unmatched_files: true
|
|
make_latest: true
|
|
body: |
|
|
## Release ${{ steps.version.outputs.VERSION }}
|
|
|
|
### Installation
|
|
|
|
Download the appropriate binary for your platform below.
|
|
|
|
#### Linux/macOS
|
|
```bash
|
|
# Download and extract
|
|
wget https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.VERSION }}/onvif-go-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz
|
|
tar xzf onvif-go-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz
|
|
|
|
# Make executable and move to PATH
|
|
chmod +x onvif-cli
|
|
sudo mv onvif-cli /usr/local/bin/onvif-cli
|
|
```
|
|
|
|
#### Windows
|
|
Download the `.zip` file for your architecture and extract it.
|
|
|
|
#### Go Library
|
|
```bash
|
|
go get github.com/${{ github.repository }}@${{ steps.version.outputs.VERSION }}
|
|
```
|
|
|
|
### Checksums
|
|
|
|
SHA256 checksums are available in `checksums.txt`
|
|
|
|
### Changes
|
|
|
|
${{ steps.version.outputs.CHANGELOG }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
docker:
|
|
name: Build and Push Docker Image
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@d632cb752374ac6c22015e4b4bef1d19db85d69f # v4.2.0
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@49b3bc8e6f341ff684fb5300544cda1ff1a290d5 # v3.2.0
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@4fd812986e6c8ec69f87869bf8f84174f3426a6d # v3.4.0
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1b4ee7e33440 # v3.3.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
continue-on-error: true
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1b4ee7e33440 # v3.3.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@5f63d2b5a0f13e6fe58a2658b1cf779280e04def # v6.2.0
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:latest
|
|
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|