Automate swift package resolve
#3156
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: pr | |
| on: | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| inputs: | |
| plugins: | |
| description: "Plugins to build and publish (i.e. connect-go:latest, connect-go, grpc/java:v1.53.0)" | |
| default: '' | |
| type: string | |
| # Prevent writing to the repository using the CI token. | |
| # Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions | |
| permissions: read-all | |
| concurrency: | |
| group: ${{ github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| pr: | |
| env: | |
| BUILDKIT_PROGRESS: plain | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| runs-on: ubuntu-latest-4-cores | |
| steps: | |
| - name: set PLUGINS from workflow inputs | |
| if: ${{ inputs.plugins }} | |
| run: echo "PLUGINS=${{ inputs.plugins }}" >> $GITHUB_ENV | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25' | |
| check-latest: true | |
| - name: Calculate changed plugins and set PLUGINS env var from base branch | |
| if: ${{ inputs.plugins == '' }} | |
| env: | |
| BASE_REF: 'origin/${{ github.base_ref }}' # we can use a remote ref because we fetch everything back in the checkout step | |
| INCLUDE_TESTDATA: 'true' | |
| run: | | |
| val=`go run ./internal/cmd/changed-plugins .` | |
| if [[ -n "${val}" && -z "${PLUGINS}" ]]; then | |
| echo "PLUGINS=${val}" >> $GITHUB_ENV | |
| fi | |
| - name: Get buf version | |
| shell: bash | |
| run: | | |
| echo BUF_VERSION=$(go list -m -f '{{.Version}}' github.com/bufbuild/buf | cut -c2-) >> $GITHUB_ENV | |
| - uses: bufbuild/buf-action@v1 | |
| with: | |
| setup_only: true | |
| - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 | |
| - name: Login to Docker Hub | |
| if: ${{ env.DOCKERHUB_USERNAME != '' }} | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lint | |
| run: make lint | |
| - name: Test | |
| run: make test | |
| - name: Archive plugin generated code | |
| uses: actions/upload-artifact@v6 | |
| if: ${{ failure() }} | |
| with: | |
| name: plugin-generated-code | |
| path: | | |
| tests/testdata/**/gen/** | |
| retention-days: 3 |