docs: 北向文档全面更新 — 增加 BACnet Server 从机模式双向读写指南 #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Workflow | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # 当推送以 v 开头的 tag 时触发,例如 v1.0.0 | |
| permissions: | |
| contents: write # 授予创建 Release 的权限 | |
| jobs: | |
| test-and-build: | |
| name: Run Tests and Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| check-latest: true | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Run unit tests | |
| env: | |
| CGO_ENABLED: '0' | |
| run: go test ./... -v -count=1 | |
| - name: Build for Linux | |
| run: | | |
| echo "Building for Linux..." | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gateway-linux-amd64 ./cmd/main.go | |
| ls -la gateway-linux-amd64 | |
| - name: Build for Windows | |
| run: | | |
| echo "Building for Windows..." | |
| CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o gateway-windows-amd64.exe ./cmd/main.go | |
| ls -la gateway-windows-amd64.exe | |
| - name: Upload Linux artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gateway-linux-amd64 | |
| path: gateway-linux-amd64 | |
| - name: Upload Windows artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gateway-windows-amd64 | |
| path: gateway-windows-amd64.exe | |
| release: | |
| name: Create Release | |
| needs: test-and-build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download Linux artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: gateway-linux-amd64 | |
| path: . | |
| - name: Download Windows artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: gateway-windows-amd64 | |
| path: . | |
| - name: Verify artifacts | |
| run: | | |
| ls -la | |
| chmod +x gateway-linux-amd64 gateway-windows-amd64.exe | |
| - name: Get tag name | |
| id: get_tag | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| echo "TAG_NAME=$TAG_NAME" | |
| echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| TAG_NAME=${{ env.TAG_NAME }} | |
| echo "Generating changelog for tag: $TAG_NAME" | |
| PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| echo "Previous tag: $PREV_TAG" | |
| if [ -n "$PREV_TAG" ]; then | |
| CHANGELOG=$(git log --oneline "$PREV_TAG..$TAG_NAME") | |
| else | |
| CHANGELOG=$(git log --oneline) | |
| fi | |
| echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV | |
| echo "Changelog generated successfully" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| name: Release ${{ env.TAG_NAME }} | |
| body: | | |
| ## Changes | |
| ${{ env.CHANGELOG }} | |
| files: | | |
| gateway-linux-amd64 | |
| gateway-windows-amd64.exe | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |