diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b72755..086fd7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,9 @@ -name: Build proxmox-service-discovery +name: Build, Tag, and Release proxmox-service-discovery on: push: branches: - - main # Сборка запускается только при пуше в ветку main + - main # Сборка и релиз запускаются только при пуше в ветку main jobs: build: @@ -16,9 +16,9 @@ jobs: steps: # Step 1: Checkout the code from the repository - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - # Step 2: Set up Go 1.31 + # Step 2: Set up Go 1.23 - name: Set up Go uses: actions/setup-go@v4 with: @@ -45,11 +45,78 @@ jobs: # Step 6: Build the proxmox-service-discovery application for the specified architecture - name: Build proxmox-service-discovery - run: go build -v -o proxmox-service-discovery-${{ matrix.goarch }} ./... + run: go build -o proxmox-service-discovery-${{ matrix.goarch }} - # Step 7: Upload the build as an artifact - - name: Upload build artifact - uses: actions/upload-artifact@v3 + # Step 7: Create a ZIP archive with the binary + - name: Package binary into a ZIP file + run: zip proxmox-service-discovery-${{ matrix.goarch }}.zip proxmox-service-discovery-${{ matrix.goarch }} + + # Step 8: Upload the ZIP archive as an artifact + - name: Upload ZIP artifact + uses: actions/upload-artifact@v4 + with: + name: proxmox-service-discovery-${{ matrix.goarch }}.zip + path: ./proxmox-service-discovery-${{ matrix.goarch }}.zip + + release: + needs: build + runs-on: ubuntu-latest + steps: + # Step 1: Checkout the code + - name: Checkout code + uses: actions/checkout@v4 + + # Step 2: Download build artifacts (ZIP files) + - name: Download ZIP artifacts for amd64 + uses: actions/download-artifact@v4 + with: + name: proxmox-service-discovery-amd64.zip + - name: Download ZIP artifacts for arm64 + uses: actions/download-artifact@v4 + with: + name: proxmox-service-discovery-arm64.zip + + # Step 3: Bump version using mathieudutour/github-tag-action + - name: Bump version and create tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tag_prefix: "v" + release_branches: "main" + default_bump: "patch" # Определяет, какое обновление версии по умолчанию: major, minor или patch + create_annotated_tag: true + + # Step 4: Create GitHub release + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + release_name: "Release ${{ steps.tag_version.outputs.new_tag }}" + draft: false + prerelease: false + + # Step 5: Upload ZIP archive for amd64 to release + - name: Upload Linux AMD64 ZIP artifact + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./proxmox-service-discovery-amd64.zip + asset_name: proxmox-service-discovery-amd64.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Step 6: Upload ZIP archive for arm64 to release + - name: Upload Linux ARM64 ZIP artifact + uses: actions/upload-release-asset@v1 with: - name: proxmox-service-discovery-${{ matrix.goarch }} - path: ./proxmox-service-discovery-${{ matrix.goarch }} + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./proxmox-service-discovery-arm64.zip + asset_name: proxmox-service-discovery-arm64.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}