diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..d8d78c1 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,68 @@ +name: Build and Release + +on: + push: + branches: [ main ] + tags: + - 'v*' + pull_request: + branches: [ main ] + +jobs: + build: + name: Build + runs-on: docker + strategy: + matrix: + goos: [linux, windows, darwin] + goarch: [amd64, arm64] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build + run: | + export GOOS=${{ matrix.goos }} + export GOARCH=${{ matrix.goarch }} + export CGO_ENABLED=0 + go build -v -o sub-cli-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} + + - name: Upload build artifact + uses: forgejo/upload-artifact@v4 + with: + name: sub-cli-${{ matrix.goos }}-${{ matrix.goarch }} + path: sub-cli-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} + retention-days: 7 + + release: + name: Create Release + needs: build + if: startsWith(github.ref, 'refs/tags/') + runs-on: docker + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download all artifacts + uses: forgejo/download-artifact@v4 + + - name: Display structure of downloaded files + run: ls -R + + - name: Create release + id: create_release + uses: https://github.com/softprops/action-gh-release@v2 + with: + name: Release ${{ github.ref_name }} + draft: false + prerelease: false + files: | + sub-cli-linux-amd64/sub-cli-linux-amd64 + sub-cli-linux-arm64/sub-cli-linux-arm64 + sub-cli-darwin-amd64/sub-cli-darwin-amd64 + sub-cli-darwin-arm64/sub-cli-darwin-arm64 + sub-cli-windows-amd64/sub-cli-windows-amd64.exe + env: + GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}