|
26 | 26 | packages: write |
27 | 27 |
|
28 | 28 | steps: |
29 | | - - uses: actions/checkout@v6 |
| 29 | + - if: github.event_name == 'release' |
| 30 | + uses: actions/checkout@v6 |
| 31 | + with: |
| 32 | + ref: ${{ github.event.release.tag_name }} |
| 33 | + - if: github.event_name != 'release' |
| 34 | + uses: actions/checkout@v6 |
| 35 | + - name: Resolve upstream ref |
| 36 | + id: version |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + set -euo pipefail |
| 40 | +
|
| 41 | + if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then |
| 42 | + raw_tag='${{ github.event.release.tag_name }}' |
| 43 | +
|
| 44 | + if [[ ! "${raw_tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(_[0-9]+)?$ ]]; then |
| 45 | + echo "::error::Invalid release tag '${raw_tag}'. Expected vX.Y.Z or vX.Y.Z_N." |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +
|
| 49 | + upstream_ref="${raw_tag%%_*}" |
| 50 | + else |
| 51 | + upstream_ref="master" |
| 52 | + fi |
| 53 | +
|
| 54 | + echo "upstream_ref=${upstream_ref}" >> "${GITHUB_OUTPUT}" |
| 55 | + - name: Verify upstream tag exists |
| 56 | + if: github.event_name == 'release' |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + set -euo pipefail |
| 60 | +
|
| 61 | + if ! git ls-remote --exit-code --tags https://github.com/librespeed/speedtest-cli.git "refs/tags/${{ steps.version.outputs.upstream_ref }}" > /dev/null; then |
| 62 | + echo "::error::Upstream tag '${{ steps.version.outputs.upstream_ref }}' not found." |
| 63 | + exit 1 |
| 64 | + fi |
30 | 65 | - uses: docker/setup-qemu-action@v4 |
31 | 66 | - uses: docker/setup-buildx-action@v4 |
32 | 67 | - uses: docker/login-action@v4 |
|
45 | 80 | with: |
46 | 81 | context: . |
47 | 82 | platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 83 | + build-args: | |
| 84 | + UPSTREAM_REF=${{ steps.version.outputs.upstream_ref }} |
48 | 85 | cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
49 | 86 | cache-to: type=inline |
50 | 87 | push: ${{ ((github.event_name == 'push' || github.event_name == 'workflow_run') && github.ref == 'refs/heads/master') || github.event_name == 'release' }} |
|
0 commit comments