Skip to content
go-libfossil Artifact [e3f04f930d]
Login

Artifact [e3f04f930d]

Artifact e3f04f930d8212ee62076e6dc275540c583b5e474cd5103ee8699a8566e9a994:


name: Release
on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      # The go-libfossil rename left temporary `replace` directives bridging the
      # in-repo modules to local paths. A tag carrying them breaks
      # `go install github.com/danmestas/go-libfossil/cmd/libfossil@<tag>` and any
      # `@version` fetch of the driver submodules, because Go refuses a main module
      # that contains replace directives. Unblock a release by cutting new tags for
      # the submodules with the corrected module paths, bumping the root module's
      # requires to those versions, then deleting the replace blocks (and the stale
      # old-path lines they leave behind in the go.sum files).
      - name: Guard against replace directives
        run: |
          offenders=$(git ls-files '*go.mod' | xargs -r grep -l '^replace' || true)
          if [ -n "$offenders" ]; then
            echo "::error::refusing to release: go.mod replace directives present in:"
            echo "$offenders"
            exit 1
          fi

      # A pseudo-version names a bare commit rather than a tag. When the commit
      # comes from a PR branch that is later squash-merged, the original is
      # rewritten and orphaned, so the require line resolves only for as long as
      # proxy.golang.org keeps its cached copy; anything on direct git (e.g.
      # GOPRIVATE=github.com/danmestas/*) fails outright. That shipped in v0.7.0
      # unnoticed because CI reads through the proxy. In-repo modules must
      # therefore reference each other by released tag only. Unblock a release by
      # pointing the offending requires at the current tag and running
      # `go mod tidy` in each affected module.
      - name: Guard against in-repo pseudo-version requires
        run: |
          offenders=$(git ls-files '*go.mod' | xargs -r grep -nE \
            'github\.com/danmestas/go-libfossil(/[^[:space:]]+)?[[:space:]]+v[0-9][^[:space:]]*[-.][0-9]{14}-[0-9a-f]{12}' || true)
          if [ -n "$offenders" ]; then
            echo "::error::refusing to release: in-repo pseudo-version requires present:"
            echo "$offenders"
            exit 1
          fi

      - name: Create GitHub release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release create "${{ github.ref_name }}" \
            --generate-notes \
            --verify-tag

      - name: Dispatch downstream bump
        env:
          GH_TOKEN: ${{ secrets.DISPATCH_PAT }}
          DOWNSTREAM: EdgeSync
          MODULE_PATH: github.com/danmestas/go-libfossil
        run: |
          gh api -X POST "repos/danmestas/${DOWNSTREAM}/dispatches" \
            -f event_type=upstream-bump \
            -f client_payload[repo]=${{ github.event.repository.name }} \
            -f client_payload[module_path]=${MODULE_PATH} \
            -f client_payload[version]=${{ github.ref_name }} \
            -f client_payload[release_url]=${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }} \
            -f client_payload[tag_sha]=${{ github.sha }} \
            -f client_payload[actor]=${{ github.actor }}