|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: release-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + release_created: ${{ steps.release.outputs.release_created }} |
| 21 | + tag_name: ${{ steps.release.outputs.tag_name }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v6 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Run release-please |
| 28 | + id: release |
| 29 | + uses: googleapis/release-please-action@v4 |
| 30 | + with: |
| 31 | + token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }} |
| 32 | + config-file: .github/release-please-config.json |
| 33 | + manifest-file: .github/.release-please-manifest.json |
| 34 | + |
| 35 | + docker-publish: |
| 36 | + if: needs.release.outputs.release_created == 'true' |
| 37 | + needs: |
| 38 | + - release |
| 39 | + runs-on: ubuntu-latest |
| 40 | + env: |
| 41 | + IMAGE_NAME: html2rss/web |
| 42 | + TAG_SHA: ${{ github.sha }} |
| 43 | + RELEASE_TAG: ${{ needs.release.outputs.tag_name }} |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v6 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + |
| 49 | + - name: Setup Node.js for Docker build |
| 50 | + uses: actions/setup-node@v6 |
| 51 | + with: |
| 52 | + node-version-file: ".tool-versions" |
| 53 | + cache: npm |
| 54 | + cache-dependency-path: frontend/package-lock.json |
| 55 | + |
| 56 | + - name: Install frontend dependencies |
| 57 | + run: npm ci |
| 58 | + working-directory: frontend |
| 59 | + |
| 60 | + - name: Build frontend static assets |
| 61 | + run: npm run build |
| 62 | + working-directory: frontend |
| 63 | + |
| 64 | + - name: Set up QEMU |
| 65 | + uses: docker/setup-qemu-action@v4 |
| 66 | + |
| 67 | + - name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v4 |
| 69 | + |
| 70 | + - name: Get Git commit timestamp |
| 71 | + run: echo "TIMESTAMP=$(git log -1 --format=%cI)" >> "$GITHUB_ENV" |
| 72 | + |
| 73 | + - name: Compute Docker tags |
| 74 | + id: tags |
| 75 | + run: | |
| 76 | + release_version="${RELEASE_TAG#v}" |
| 77 | + echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV" |
| 78 | + major="${release_version%%.*}" |
| 79 | + { |
| 80 | + echo "tags<<EOF" |
| 81 | + echo "${IMAGE_NAME}:${release_version}" |
| 82 | + echo "${IMAGE_NAME}:${major}" |
| 83 | + echo "${IMAGE_NAME}:latest" |
| 84 | + echo "${IMAGE_NAME}:${TAG_SHA}" |
| 85 | + echo "EOF" |
| 86 | + } >> "$GITHUB_OUTPUT" |
| 87 | +
|
| 88 | + - name: Log in to DockerHub |
| 89 | + uses: docker/login-action@v4 |
| 90 | + with: |
| 91 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 92 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 93 | + |
| 94 | + - name: Cache Docker layers |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: /tmp/.buildx-cache |
| 98 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 99 | + restore-keys: | |
| 100 | + ${{ runner.os }}-buildx- |
| 101 | +
|
| 102 | + - name: Build and push Docker image |
| 103 | + uses: docker/build-push-action@v7 |
| 104 | + env: |
| 105 | + SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }} |
| 106 | + with: |
| 107 | + context: . |
| 108 | + push: true |
| 109 | + tags: ${{ steps.tags.outputs.tags }} |
| 110 | + build-args: | |
| 111 | + BUILD_TAG=${{ env.RELEASE_VERSION }} |
| 112 | + GIT_SHA=${{ github.sha }} |
| 113 | + platforms: linux/amd64,linux/arm64 |
| 114 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 115 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 116 | + provenance: true |
| 117 | + sbom: true |
| 118 | + labels: | |
| 119 | + org.opencontainers.image.created=${{ env.TIMESTAMP }} |
| 120 | + org.opencontainers.image.description=Generates RSS feeds of any website & serves to the web! |
| 121 | + org.opencontainers.image.ref.name=${{ env.RELEASE_TAG }} |
| 122 | + org.opencontainers.image.revision=${{ github.sha }} |
| 123 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 124 | + org.opencontainers.image.title=html2rss-web |
| 125 | + org.opencontainers.image.url=https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_TAG }} |
| 126 | + org.opencontainers.image.version=${{ env.RELEASE_VERSION }} |
| 127 | +
|
| 128 | + - name: Move updated cache into place |
| 129 | + run: | |
| 130 | + rm -rf /tmp/.buildx-cache |
| 131 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments