From 8e30741e371621756dd46ae0e54e53a4b34f1abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 3 Mar 2025 06:16:34 +0100 Subject: [PATCH] ci: Initial build script --- .github/workflows/github-actions.yml | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/github-actions.yml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..7cc8654 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,60 @@ +name: Build and Release Go App + +on: + push: + tags: + - 'v*' # Runs only when a new version tag is pushed + +jobs: + build: + name: Build Go App + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + goarch: [amd64] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + + - name: Set environment variables + run: | + echo "GOOS=${{ runner.os == 'Windows' && 'windows' || runner.os == 'macos' && 'darwin' || 'linux' }}" >> $GITHUB_ENV + echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV + + - name: Build application + run: | + mkdir -p dist + go build -C ./src -o dist/alma-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOOS == 'windows' && '.exe' || '' }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: app-${{ env.GOOS }}-${{ env.GOARCH }} + path: src/dist/* + + release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: build + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: dist + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + files: dist/**/* + draft: false + prerelease: false + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +