diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f760cc6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,76 @@ +name: Build and Release + +on: + push: + branches: [ "main", "master" ] + tags: [ "v*" ] + pull_request: + branches: [ "main", "master" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + cache: true + + - name: Run tests + run: go test ./... + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: true + + - name: Build binaries + run: make all + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: binaries + path: build/* + retention-days: 7 + + release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: binaries + path: build + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: | + build/wg-fake.linux-amd64 + build/wg-fake.linux-386 + build/wg-fake.linux-arm + build/wg-fake.linux-arm64 + build/wg-fake.darwin-amd64 + build/wg-fake.darwin-arm64 + build/wg-fake.windows-amd64.exe + build/wg-fake.windows-386.exe + build/wg-fake.windows-arm.exe + generate_release_notes: true \ No newline at end of file