Allow dotted v.* release tags in workflow metadata #19
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| - "v.*.*.*" | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| BROWSER_UPSTREAM: ghcr.io/browserless/chromium | |
| BROWSER_VERSION: v2.44.0 | |
| jobs: | |
| mirror-browser: | |
| name: mirror-browser | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull, tag, and push browser image | |
| run: | | |
| src="${BROWSER_UPSTREAM}:${BROWSER_VERSION}" | |
| dst="ghcr.io/${GITHUB_REPOSITORY@L}-browser" | |
| docker pull "$src" | |
| docker tag "$src" "$dst:${BROWSER_VERSION}" | |
| docker tag "$src" "$dst:latest" | |
| docker push "$dst:${BROWSER_VERSION}" | |
| docker push "$dst:latest" | |
| release: | |
| name: publish-${{ matrix.image.name }} | |
| needs: mirror-browser | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: | |
| - name: web | |
| dockerfile: Dockerfile | |
| image_suffix: -web | |
| - name: collector | |
| dockerfile: Dockerfile.collector | |
| image_suffix: -collector | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: .nvmrc | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build release bundle | |
| env: | |
| APP_VERSION: ${{ github.ref_name }} | |
| run: npm run build | |
| - name: Archive dist | |
| if: matrix.image.name == 'web' | |
| run: | | |
| tar -czf euosint-dist-${GITHUB_REF_NAME}.tar.gz dist | |
| shasum -a 256 euosint-dist-${GITHUB_REF_NAME}.tar.gz > euosint-dist-${GITHUB_REF_NAME}.tar.gz.sha256 | |
| - name: Prepare image name | |
| id: image | |
| run: echo "name=ghcr.io/${GITHUB_REPOSITORY@L}${{ matrix.image.image_suffix }}" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ steps.image.outputs.name }} | |
| tags: | | |
| type=raw,value=${{ github.ref_name }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=sha | |
| type=raw,value=latest | |
| - name: Build and push image (attempt 1) | |
| id: build_push_1 | |
| continue-on-error: true | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./${{ matrix.image.dockerfile }} | |
| push: true | |
| provenance: false | |
| build-args: | | |
| APP_VERSION=${{ github.ref_name }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=release-${{ matrix.image.name }} | |
| cache-to: type=gha,mode=max,scope=release-${{ matrix.image.name }} | |
| - name: Build and push image (attempt 2 on transient failure) | |
| if: steps.build_push_1.outcome == 'failure' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./${{ matrix.image.dockerfile }} | |
| push: true | |
| provenance: false | |
| build-args: | | |
| APP_VERSION=${{ github.ref_name }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=release-${{ matrix.image.name }} | |
| cache-to: type=gha,mode=max,scope=release-${{ matrix.image.name }} | |
| - name: Publish GitHub release | |
| if: matrix.image.name == 'web' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then | |
| gh release upload "${GITHUB_REF_NAME}" \ | |
| "euosint-dist-${GITHUB_REF_NAME}.tar.gz" \ | |
| "euosint-dist-${GITHUB_REF_NAME}.tar.gz.sha256" \ | |
| --clobber | |
| else | |
| gh release create "${GITHUB_REF_NAME}" \ | |
| "euosint-dist-${GITHUB_REF_NAME}.tar.gz" \ | |
| "euosint-dist-${GITHUB_REF_NAME}.tar.gz.sha256" \ | |
| --generate-notes | |
| fi |