Skip to content

Commit 3257809

Browse files
committed
Add release workflow and update README badges
Introduces a workflow for automated releases to Hex, including integration testing with ClickHouse and automated tagging. Updates the README to include a Hex.pm badge for the package.
1 parent 25c52f6 commit 3257809

2 files changed

Lines changed: 130 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
pull_request:
7+
types: [closed]
8+
branches: [main]
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
id-token: write
14+
15+
jobs:
16+
release:
17+
name: Release to Hex
18+
runs-on: ubuntu-latest
19+
if: >-
20+
contains(github.ref, 'refs/tags/') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Start ClickHouse (for integration tests)
28+
run: |
29+
# If you keep the repository's docker-compose.yml with a service named `clickhouse` this will start it.
30+
docker compose up -d clickhouse || true
31+
echo "Waiting for ClickHouse to be ready..."
32+
for i in $(seq 1 60); do
33+
if curl -sSf http://localhost:8123/ >/dev/null 2>&1; then
34+
echo "ClickHouse is ready"
35+
break
36+
fi
37+
sleep 2
38+
done
39+
40+
- name: Setup Erlang/OTP and Gleam
41+
uses: erlef/setup-beam@v1
42+
with:
43+
otp-version: "27.0"
44+
gleam-version: "1.13.0"
45+
46+
- name: Show versions
47+
run: |
48+
erl -version || true
49+
gleam --version
50+
51+
- name: Cache Gleam deps and build
52+
uses: actions/cache@v4
53+
with:
54+
path: |
55+
~/.cache/gleam
56+
~/.gleam
57+
./_gleam_deps
58+
./build
59+
key: ${{ runner.os }}-gleam-1.13.0-otp27-release-${{ hashFiles('**/gleam.toml') }}
60+
restore-keys: |
61+
${{ runner.os }}-gleam-1.13.0-otp27-release-
62+
63+
- name: Install dependencies
64+
run: gleam deps download
65+
66+
- name: Check formatting
67+
run: gleam format --check src test
68+
69+
- name: Build
70+
run: gleam build
71+
72+
- name: Run tests
73+
env:
74+
CLICKHOUSE_USER: test_user
75+
CLICKHOUSE_PASSWORD: test_password
76+
CLICKHOUSE_DB: test_db
77+
CLICKHOUSE_URL: http://localhost:8123
78+
run: gleam test
79+
80+
- name: Create tag from gleam.toml (on merged PR)
81+
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
82+
run: |
83+
set -euo pipefail
84+
VERSION=$(grep '^version' gleam.toml | sed -E 's/.*= *"([^"]+)".*/\1/')
85+
TAG="v${VERSION}"
86+
echo "Derived tag: ${TAG}"
87+
# Ensure we have refs to push
88+
git fetch origin --tags
89+
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
90+
echo "Tag ${TAG} already exists, skipping"
91+
exit 0
92+
fi
93+
94+
git config user.name "github-actions[bot]"
95+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
96+
git tag -a "${TAG}" -m "Release ${TAG}"
97+
# Push using the default authentication provided to the runner (GITHUB_TOKEN)
98+
git push origin "${TAG}"
99+
echo "Pushed tag ${TAG} to origin"
100+
101+
- name: Validate package (dry-run)
102+
run: |
103+
echo "Validating package before publishing..."
104+
gleam publish --dry-run
105+
106+
- name: Publish to Hex
107+
env:
108+
HEXPM_API_KEY: ${{ secrets.HEX_API_KEY }}
109+
run: |
110+
echo "Publishing package to Hex..."
111+
gleam publish --yes
112+
113+
- name: Create GitHub Release
114+
if: startsWith(github.ref, 'refs/tags/')
115+
uses: softprops/action-gh-release@v1
116+
with:
117+
body: |
118+
Release ${{ github.ref_name }}
119+
120+
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for details.
121+
draft: false
122+
prerelease: false
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
126+
- name: Cleanup ClickHouse
127+
if: always()
128+
run: docker compose down -v || true

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<img src="assets/image.png" alt="Sparkling logo" width="240" />
55
</p>
66

7-
[![CI](https://github.com/lupodevelop/sparkling/actions/workflows/ci.yml/badge.svg)](https://github.com/lupodevelop/sparkling/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-Apache%202.0-yellow.svg)](LICENSE) [![Built with Gleam](https://img.shields.io/badge/Built%20with-Gleam-ffaff3)](https://gleam.run) [![Gleam Version](https://img.shields.io/badge/gleam-%3E%3D1.13.0-ffaff3)](https://gleam.run)
7+
[![CI](https://github.com/lupodevelop/sparkling/actions/workflows/ci.yml/badge.svg)](https://github.com/lupodevelop/sparkling/actions/workflows/ci.yml) [![Hex](https://img.shields.io/hexpm/v/sparkling.svg)](https://hex.pm/packages/sparkling) [![License](https://img.shields.io/badge/license-Apache%202.0-yellow.svg)](LICENSE) [![Built with Gleam](https://img.shields.io/badge/Built%20with-Gleam-ffaff3)](https://gleam.run) [![Gleam Version](https://img.shields.io/badge/gleam-%3E%3D1.13.0-ffaff3)](https://gleam.run)
88

99
**Sparkling** is a *lightweight*, **type-safe** data layer for **ClickHouse** written in Gleam. It provides a small, focused API for defining schemas, building queries, and encoding/decoding ClickHouse formats.
10-
10+
É
1111
*No magic*, just small, composable functions that play nicely in Gleam apps.
1212

1313
> Why "Sparkling"? One rainy Tuesday a tiny inflatable rubber duck stole a shooting pink star and decided to become a freelance data wrangler, and it now guides queries through the night, humming 8-bit lullabies. Totally plausible.

0 commit comments

Comments
 (0)