Skip to content

Commit d6deffc

Browse files
committed
ci: add please-release
1 parent aeb414c commit d6deffc

10 files changed

Lines changed: 237 additions & 90 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.0.0"
3+
}

.github/release-please-config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"packages": {
3+
".": {
4+
"release-type": "ruby",
5+
"package-name": "html2rss-web",
6+
"version-file": "config/version.rb",
7+
"changelog-path": "CHANGELOG.md"
8+
}
9+
}
10+
}

.github/workflows/ci.yml

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -159,91 +159,3 @@ jobs:
159159
DOCKER_SMOKE_SKIP_BUILD: "true"
160160
SMOKE_AUTO_SOURCE_ENABLED: ${{ matrix.smoke_auto_source_enabled }}
161161
run: bundle exec rake
162-
163-
docker-publish:
164-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
165-
needs:
166-
- docker-test
167-
runs-on: ubuntu-latest
168-
permissions:
169-
contents: read
170-
packages: write
171-
env:
172-
IMAGE_NAME: html2rss/web
173-
TAG_SHA: ${{ github.sha }}
174-
steps:
175-
- name: Checkout code
176-
uses: actions/checkout@v6
177-
178-
- name: Setup Node.js for Docker build
179-
uses: actions/setup-node@v6
180-
with:
181-
node-version-file: ".tool-versions"
182-
cache: npm
183-
cache-dependency-path: frontend/package-lock.json
184-
185-
- name: Install frontend dependencies
186-
run: npm ci
187-
working-directory: frontend
188-
189-
- name: Build frontend static assets
190-
run: npm run build
191-
working-directory: frontend
192-
193-
- name: Set up QEMU
194-
uses: docker/setup-qemu-action@v4
195-
196-
- name: Set up Docker Buildx
197-
uses: docker/setup-buildx-action@v4
198-
199-
- name: Get Git commit timestamps
200-
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
201-
202-
- name: Extract metadata
203-
id: meta
204-
uses: docker/metadata-action@v6
205-
with:
206-
images: ${{ env.IMAGE_NAME }}
207-
208-
- name: Log in to DockerHub
209-
uses: docker/login-action@v4
210-
with:
211-
username: ${{ secrets.DOCKER_USERNAME }}
212-
password: ${{ secrets.DOCKER_PASSWORD }}
213-
214-
- name: Cache Docker layers
215-
uses: actions/cache@v5
216-
with:
217-
path: /tmp/.buildx-cache
218-
key: ${{ runner.os }}-buildx-${{ github.sha }}
219-
restore-keys: |
220-
${{ runner.os }}-buildx-
221-
222-
- name: Build and push Docker image
223-
uses: docker/build-push-action@v7
224-
env:
225-
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
226-
with:
227-
context: .
228-
push: true
229-
tags: |
230-
html2rss/web:latest
231-
html2rss/web:${{ github.sha }}
232-
${{ steps.meta.outputs.tags }}
233-
platforms: linux/amd64,linux/arm64
234-
cache-from: type=local,src=/tmp/.buildx-cache
235-
cache-to: type=local,dest=/tmp/.buildx-cache-new
236-
provenance: true
237-
sbom: true
238-
labels: |
239-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
240-
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
241-
org.opencontainers.image.revision=${{ github.sha }}
242-
org.opencontainers.image.title=html2rss-web
243-
org.opencontainers.image.description=Generates RSS feeds of any website & serves to the web!
244-
org.opencontainers.image.sbom=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts
245-
246-
- name: Move updated cache into place
247-
run: |
248-
rm -rf /tmp/.buildx-cache
249-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

.github/workflows/release.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: refresh release artifacts
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
concurrency:
17+
group: release-artifacts-${{ github.event.pull_request.number }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
refresh-generated-artifacts:
22+
if: github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.event.pull_request.head.ref, 'release-please--branches--')
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v6
27+
with:
28+
ref: ${{ github.event.pull_request.head.ref }}
29+
fetch-depth: 0
30+
31+
- uses: ruby/setup-ruby@v1
32+
with:
33+
bundler-cache: true
34+
35+
- uses: actions/setup-node@v6
36+
with:
37+
node-version-file: ".tool-versions"
38+
cache: npm
39+
cache-dependency-path: frontend/package-lock.json
40+
41+
- name: Install frontend dependencies
42+
run: npm ci
43+
working-directory: frontend
44+
45+
- name: Refresh OpenAPI artifacts
46+
run: |
47+
make openapi
48+
make openapi-client
49+
50+
- name: Commit generated artifacts
51+
run: |
52+
if git diff --quiet -- public/openapi.yaml frontend/src/api/generated; then
53+
echo "Generated artifacts already up to date"
54+
exit 0
55+
fi
56+
57+
git config user.name "github-actions[bot]"
58+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
59+
git add public/openapi.yaml frontend/src/api/generated
60+
git commit -m "chore: refresh release artifacts"
61+
git push

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ LABEL maintainer="Gil Desmarais <html2rss-web-docker@desmarais.de>"
4545

4646
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
4747

48+
ARG BUILD_TAG=unknown
49+
ARG GIT_SHA=unknown
50+
4851
ENV PORT=4000 \
4952
RACK_ENV=production \
50-
RUBY_YJIT_ENABLE=1
53+
RUBY_YJIT_ENABLE=1 \
54+
BUILD_TAG=${BUILD_TAG} \
55+
GIT_SHA=${GIT_SHA}
5156

5257
EXPOSE $PORT
5358

config/version.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
module Html2rss
4+
module Web
5+
VERSION = '1.0.0'
6+
public_constant :VERSION
7+
end
8+
end

spec/html2rss/web_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
require_relative '../../config/version'
6+
7+
RSpec.describe Html2rss::Web do
8+
describe 'VERSION' do
9+
it 'defines the canonical application release version' do
10+
expect(described_class::VERSION).to eq('1.0.0')
11+
end
12+
end
13+
end

spec/support/openapi.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
return unless ENV['OPENAPI']
44

55
require 'rspec/openapi'
6+
require_relative '../../config/version'
67

78
RSpec::OpenAPI.path = 'public/openapi.yaml'
89
RSpec::OpenAPI.title = 'html2rss-web API'
9-
RSpec::OpenAPI.application_version = '1.0.0'
10+
RSpec::OpenAPI.application_version = Html2rss::Web::VERSION
1011
RSpec::OpenAPI.enable_example = false
1112
RSpec::OpenAPI.enable_example_summary = false
1213
RSpec::OpenAPI.example_types = [:request]

0 commit comments

Comments
 (0)