From 3cacfa0d412796fb6547a8710671a5ae66e67f34 Mon Sep 17 00:00:00 2001 From: Marcel Schramm Date: Sun, 10 Mar 2024 16:14:34 +0100 Subject: [PATCH] Add build and release pipelines --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0d407d4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: build + +on: + push: + tags: [v**] + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.x + + - name: Run tests + shell: bash + run: | + go test -v -race -covermode=atomic ./... + + - name: Build artifact + shell: bash + run: | + go build -trimpath -ldflags "-w -s" -o spoon.exe ./cmd/spoon + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: spoon.exe + path: spoon.exe + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..88833bb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: release + +on: + workflow_run: + workflows: [build] + branches: [v**] + types: [completed] + +jobs: + publish-release: + runs-on: ubuntu-latest + # Kinda bad since it might release on any branch starting with v, but it'll do for now. + # Tag filtering in "on:" doesn't work, since the inital build trigger gets lost. + # github.ref is therefore also being reset to "refs/head/master". + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Download windows artifact + uses: dawidd6/action-download-artifact@v3 + with: + workflow: build.yml + name: spoon.exe + + - name: Create release + uses: softprops/action-gh-release@v1 + with: + name: ${{ github.event.workflow_run.head_branch }} + tag_name: ${{ github.event.workflow_run.head_branch }} + files: | + spoon.exe