From b7f3296c9fc941ee1d74d911d2664021a2fb4e5d Mon Sep 17 00:00:00 2001 From: sam-k0 <56673835+sam-k0@users.noreply.github.com> Date: Sat, 28 Sep 2024 12:36:38 +0200 Subject: [PATCH] Update buildfile --- .github/workflows/release.yml | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0926def..3c8c523 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,8 @@ name: Go Build and Release on: - push: - branches: - - main # This will trigger on pushes to the 'main' branch - pull_request: - branches: - - main # This will also trigger on pull requests targeting the 'main' branch + release: + types: [published] # This triggers the workflow when a new release is published jobs: build: @@ -27,10 +23,12 @@ jobs: - name: Build the Go project run: go build -v ./... + - name: Run tests + run: go test ./... + release: needs: build # This job runs after the build job succeeds runs-on: ubuntu-latest - if: github.event_name == 'push' # Only runs on push events, not pull requests steps: - name: Checkout code @@ -39,22 +37,22 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.23' # Ensure the Go environment is set + go-version: '1.23' + + - name: Upload build artifacts to the release + uses: actions/upload-artifact@v3 + with: + name: go-build + path: ./archivist_go - - name: Create a GitHub release + - name: Update the GitHub release id: create_release uses: softprops/action-gh-release@v1 with: - tag_name: ${{ github.sha }} # Use the commit SHA as the tag name - name: Release ${{ github.sha }} # Use the commit SHA as the release name + tag_name: ${{ github.event.release.tag_name }} + name: ${{ github.event.release.tag_name }} body: | - Automated release from commit: ${{ github.sha }}. + This is an automated release for version ${{ github.event.release.tag_name }}. env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub provides this secret automatically - - - name: Upload build artifacts to the release - uses: actions/upload-artifact@v3 - with: - name: go-build - path: ./archivist_go # Adjust to the actual build output file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}