From 972ffc078af778af9df6a7d7ecf236b93fcb47e7 Mon Sep 17 00:00:00 2001 From: Salastil Date: Sun, 23 Nov 2025 02:33:31 -0500 Subject: [PATCH] Build configs --- .gitea/workflows/release.yml | 118 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 118 ++++++++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+) create mode 100644 .gitea/workflows/release.yml create mode 100644 .github/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..3722f23 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,118 @@ +name: Build release binaries + +on: + release: + types: [published] + +permissions: + contents: write + +env: + BINARY_NAME: streamed-tui + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - goos: linux + goarch: amd64 + archive: tar.gz + extension: "" + - goos: linux + goarch: arm64 + archive: tar.gz + extension: "" + - goos: windows + goarch: amd64 + archive: zip + extension: ".exe" + - goos: darwin + goarch: amd64 + archive: tar.gz + extension: "" + - goos: darwin + goarch: arm64 + archive: tar.gz + extension: "" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Build ${{ matrix.goos }} ${{ matrix.goarch }} binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + EXTENSION: ${{ matrix.extension }} + run: | + mkdir -p dist + OUTPUT="${BINARY_NAME}${EXTENSION}" + go build -o "dist/${OUTPUT}" . + + - name: Package artifact + env: + EXTENSION: ${{ matrix.extension }} + run: | + cd dist + OUTPUT="${BINARY_NAME}${EXTENSION}" + ARCHIVE="${BINARY_NAME}_${{ matrix.goos }}_${{ matrix.goarch }}" + if [ "${{ matrix.archive }}" = "zip" ]; then + zip "${ARCHIVE}.zip" "${OUTPUT}" + else + tar -czf "${ARCHIVE}.tar.gz" "${OUTPUT}" + fi + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BINARY_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }} + path: dist/${{ env.BINARY_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }}.* + if-no-files-found: error + + publish: + runs-on: ubuntu-latest + needs: build + permissions: + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - name: Publish release assets on GitHub + if: startsWith(github.server_url, 'https://github.com') + uses: softprops/action-gh-release@v2 + with: + files: dist/* + + - name: Publish release assets on Gitea + if: startsWith(github.server_url, 'https://github.com') == false + env: + API_URL: ${{ github.api_url }} + REPOSITORY: ${{ github.repository }} + RELEASE_ID: ${{ github.event.release.id }} + TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} + run: | + set -euo pipefail + shopt -s nullglob + for file in dist/*; do + name=$(basename "${file}") + curl -sfSL -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"${file}" \ + "${API_URL}/repos/${REPOSITORY}/releases/${RELEASE_ID}/assets?name=${name}" + done + shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3722f23 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,118 @@ +name: Build release binaries + +on: + release: + types: [published] + +permissions: + contents: write + +env: + BINARY_NAME: streamed-tui + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - goos: linux + goarch: amd64 + archive: tar.gz + extension: "" + - goos: linux + goarch: arm64 + archive: tar.gz + extension: "" + - goos: windows + goarch: amd64 + archive: zip + extension: ".exe" + - goos: darwin + goarch: amd64 + archive: tar.gz + extension: "" + - goos: darwin + goarch: arm64 + archive: tar.gz + extension: "" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Build ${{ matrix.goos }} ${{ matrix.goarch }} binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + EXTENSION: ${{ matrix.extension }} + run: | + mkdir -p dist + OUTPUT="${BINARY_NAME}${EXTENSION}" + go build -o "dist/${OUTPUT}" . + + - name: Package artifact + env: + EXTENSION: ${{ matrix.extension }} + run: | + cd dist + OUTPUT="${BINARY_NAME}${EXTENSION}" + ARCHIVE="${BINARY_NAME}_${{ matrix.goos }}_${{ matrix.goarch }}" + if [ "${{ matrix.archive }}" = "zip" ]; then + zip "${ARCHIVE}.zip" "${OUTPUT}" + else + tar -czf "${ARCHIVE}.tar.gz" "${OUTPUT}" + fi + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BINARY_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }} + path: dist/${{ env.BINARY_NAME }}_${{ matrix.goos }}_${{ matrix.goarch }}.* + if-no-files-found: error + + publish: + runs-on: ubuntu-latest + needs: build + permissions: + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - name: Publish release assets on GitHub + if: startsWith(github.server_url, 'https://github.com') + uses: softprops/action-gh-release@v2 + with: + files: dist/* + + - name: Publish release assets on Gitea + if: startsWith(github.server_url, 'https://github.com') == false + env: + API_URL: ${{ github.api_url }} + REPOSITORY: ${{ github.repository }} + RELEASE_ID: ${{ github.event.release.id }} + TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} + run: | + set -euo pipefail + shopt -s nullglob + for file in dist/*; do + name=$(basename "${file}") + curl -sfSL -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"${file}" \ + "${API_URL}/repos/${REPOSITORY}/releases/${RELEASE_ID}/assets?name=${name}" + done + shell: bash