name: Publish Go package on: push: tags: - 'backend/v*' release: types: - published jobs: publish: name: Publish shared Go module runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout source uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: backend/go.mod cache: false - name: Test Go module working-directory: backend run: go test ./... - name: Install ZIP tools run: sudo apt-get update && sudo apt-get install --no-install-recommends -y zip - name: Package Go module env: RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }} run: bash scripts/package-go-module.sh "$RELEASE_TAG" "$RUNNER_TEMP/gitea-go-package" - name: Publish to Gitea Package Registry env: PACKAGE_REGISTRY_USERNAME: ${{ secrets.PACKAGE_REGISTRY_USERNAME }} PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }} GITEA_GO_REGISTRY: https://repos.gfranz.ch/api/packages/Gabriel20xx/go/upload run: | set -euo pipefail if [ -z "$PACKAGE_REGISTRY_USERNAME" ] || [ -z "$PACKAGE_REGISTRY_TOKEN" ]; then echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2 exit 1 fi package_file="$(find "$RUNNER_TEMP/gitea-go-package" -maxdepth 1 -type f -name '*.zip' -print -quit)" test -n "$package_file" curl --fail-with-body --user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \ --upload-file "$package_file" \ "$GITEA_GO_REGISTRY"