Repository navigation
175 lines (152 loc) · 6.13 KB
/
Copy pathrelease.yml
File metadata and controls
175 lines (152 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Release Binaries & Container Image
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release_tag:
description: "Release tag to create/update on GitHub Releases (e.g. v0.9.4)"
required: false
default: "v0.9.4"
permissions:
contents: write
packages: write
jobs:
check-release-tag:
name: Check tag matches version files
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Tags can't be moved or deleted, and every later job publishes, so stop here on a mismatch.
- name: Compare the release tag with the version files
env:
RELEASE_TAG: ${{ github.event.inputs.release_tag || github.ref_name }}
run: |
cargo_v=$(grep -m1 '^version' control-plane/Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
py_v=$(grep -m1 '^version' client-py/pyproject.toml | sed 's/.*"\(.*\)".*/\1/')
init_v=$(grep -m1 '__version__' client-py/hypercache/__init__.py | sed 's/.*"\(.*\)".*/\1/')
echo "tag=$RELEASE_TAG Cargo.toml=$cargo_v pyproject=$py_v __init__=$init_v"
for version in "$cargo_v" "$py_v" "$init_v"; do
if [ "$RELEASE_TAG" != "v$version" ]; then
echo "::error::Release tag $RELEASE_TAG does not match version $version"
exit 1
fi
done
build-linux-binaries:
name: Build Linux x86_64 Binaries
runs-on: ubuntu-22.04
needs: check-release-tag
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo registry and target
uses: Swatinem/rust-cache@v2
with:
workspaces: "control-plane -> target"
- name: Run Rust unit test suite
run: cargo test --locked --manifest-path control-plane/Cargo.toml
- name: Run Python client test suite
env:
PYTHONPATH: client-py
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "numpy>=1.22" "fsspec>=2023.1.0" pytest
python3 -m pytest -q client-py/tests
- name: Build release binaries (hypercache & hypercache-admin)
run: |
cargo build --locked --release --manifest-path control-plane/Cargo.toml
strip control-plane/target/release/hypercache
strip control-plane/target/release/hypercache-admin
- name: Build Python wheel (client-py)
run: |
python3 -m pip install --upgrade pip build
python3 -m build --wheel client-py --outdir dist/
- name: Package release archive & checksums
run: |
mkdir -p dist/hypercache-linux-x86_64/configs
cp control-plane/target/release/hypercache dist/hypercache-linux-x86_64/
cp control-plane/target/release/hypercache-admin dist/hypercache-linux-x86_64/
cp configs/hypercache-agent.toml dist/hypercache-linux-x86_64/configs/
cp configs/hypercache-controller.toml dist/hypercache-linux-x86_64/configs/
cp -r client-py dist/hypercache-linux-x86_64/client-py
cp LICENSE README.md dist/hypercache-linux-x86_64/
# Create tarball and standalone binaries
tar -C dist/hypercache-linux-x86_64 -czf dist/hypercache-linux-x86_64.tar.gz .
cp control-plane/target/release/hypercache dist/hypercache-linux-x86_64-bin
cp control-plane/target/release/hypercache-admin dist/hypercache-admin-linux-x86_64-bin
cd dist
sha256sum hypercache-linux-x86_64.tar.gz hypercache-linux-x86_64-bin hypercache-admin-linux-x86_64-bin *.whl > SHA256SUMS
- name: Upload artifacts to GitHub Release
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.release_tag || github.ref_name }}
generate_release_notes: true
files: |
dist/hypercache-linux-x86_64.tar.gz
dist/hypercache-linux-x86_64-bin
dist/hypercache-admin-linux-x86_64-bin
dist/*.whl
dist/SHA256SUMS
publish-container-image:
name: Build & Push Docker Image (GHCR)
runs-on: ubuntu-22.04
needs: build-linux-binaries
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry (ghcr.io)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata (tags & labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push container image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish-pypi:
name: Publish Python Package (hypercache-io) to PyPI
runs-on: ubuntu-22.04
needs: build-linux-binaries
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build sdist and wheel for hypercache-io
run: |
python -m pip install --upgrade pip build
python -m build client-py --outdir dist-pypi/
- name: Publish to PyPI (when PYPI_API_TOKEN secret is set)
if: env.PYPI_API_TOKEN != ''
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist-pypi/
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true