Skip to content

Commit 616885f

Browse files
committed
feat: add self-referential hashing and tighten GH workflows
1 parent 8e50bbe commit 616885f

File tree

31 files changed

+2738
-455
lines changed

31 files changed

+2738
-455
lines changed

.cigen/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ dynamic: true # Generate separate workflow files
66
source_file_groups:
77
rust:
88
- "src/**/*.rs"
9+
- "plugins/**/*.rs"
10+
- "build.rs"
11+
- "proto/**/*.proto"
912
- "Cargo.toml"
1013
- "Cargo.lock"
1114

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
image: rust:latest
2+
3+
steps:
4+
- run:
5+
name: Install build dependencies
6+
command: |
7+
set -e
8+
apt-get update
9+
apt-get install -y nodejs npm protobuf-compiler
10+
11+
- name: Restore target cache
12+
uses: actions/cache@v4
13+
with:
14+
path: |
15+
target/release
16+
key: target-release-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
17+
18+
- run:
19+
name: Build cigen binary
20+
command: cargo build --release --bin cigen
21+
22+
- run:
23+
name: Prepare artifact bundle
24+
command: |
25+
set -e
26+
mkdir -p .cigen/bin
27+
cp target/release/cigen .cigen/bin/cigen
28+
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: cigen-bin
32+
path: .cigen/bin/cigen

.cigen/workflows/docs/jobs/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ requires:
44
- ci_gate
55

66
steps:
7-
- uses: actions/checkout@v4
8-
97
- name: Setup Node.js
108
uses: actions/setup-node@v4
119
with:

.cigen/workflows/docs/jobs/ci_gate.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
image: ubuntu-latest
22

33
steps:
4-
- uses: actions/checkout@v4
54
- name: Wait for CI checks to complete
65
uses: actions/github-script@v7
76
with:

.cigen/workflows/docs/jobs/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires:
55

66
environment:
77
name: github-pages
8-
url: ${{ steps.deployment.outputs.page_url }}
8+
url: https://docspring.github.io/cigen/
99

1010
steps:
1111
- name: Deploy to GitHub Pages

.cigen/workflows/release/jobs/docker_image.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ env:
1010
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
1111
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
1212

13-
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
13+
checkout:
14+
fetch-depth: 0
1815

19-
- id: v
20-
name: Extract version
16+
steps:
17+
- name: Extract version
2118
run: |
2219
VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
23-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
20+
echo "DOCKER_IMAGE_VERSION=$VERSION" >> "$GITHUB_ENV"
2421
2522
- name: Set up QEMU
2623
uses: docker/setup-qemu-action@v3
@@ -38,7 +35,7 @@ steps:
3835
name: Build and push multi-arch image
3936
command: |
4037
set -euo pipefail
41-
VERSION="${{ steps.v.outputs.version }}"
38+
VERSION="${{ env.DOCKER_IMAGE_VERSION }}"
4239
echo "Building docspringcom/cigen:${VERSION} and :latest"
4340
docker buildx build \
4441
--platform linux/amd64,linux/arm64 \

.cigen/workflows/release/jobs/release_build.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Dynamic runs-on from matrix
22
image: ${{ matrix.os }}
33

4+
checkout:
5+
fetch-depth: 0
6+
fetch-tags: true
7+
48
strategy:
59
fail-fast: false
610
matrix:
@@ -22,12 +26,6 @@ strategy:
2226
use-cross: true
2327

2428
steps:
25-
- name: Checkout repository
26-
uses: actions/checkout@v4
27-
with:
28-
fetch-depth: 0
29-
fetch-tags: true
30-
3129
- name: Wait for required checks
3230
uses: actions/github-script@v7
3331
with:
@@ -40,6 +38,14 @@ steps:
4038
with:
4139
targets: ${{ matrix.target }}
4240

41+
- run:
42+
name: Install Linux build dependencies
43+
command: |
44+
set -e
45+
sudo apt-get update
46+
sudo apt-get install -y protobuf-compiler
47+
if: runner.os == 'Linux'
48+
4349
- name: Install cross (for cross-compilation)
4450
if: matrix.use-cross
4551
run: cargo install cross --git https://github.com/cross-rs/cross

.cigen/workflows/release/jobs/release_create.yml

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,31 @@ image: ubuntu-latest
33
requires:
44
- release_build
55

6-
steps:
7-
- name: Checkout repository
8-
uses: actions/checkout@v4
9-
with:
10-
fetch-depth: 0
11-
fetch-tags: true
6+
checkout:
7+
fetch-depth: 0
8+
fetch-tags: true
129

10+
steps:
1311
- name: Download artifacts
1412
uses: actions/download-artifact@v4
1513
with:
1614
path: artifacts
1715

18-
- id: version
19-
name: Get version from Cargo.toml
16+
- name: Get version from Cargo.toml
2017
run: |
2118
VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
22-
{
23-
echo "version=$VERSION"
24-
} >> "$GITHUB_OUTPUT"
25-
2619
if [ "${{ github.event_name }}" = "push" ]; then
2720
TAG="${GITHUB_REF#refs/tags/}"
2821
EXPECTED_TAG="v$VERSION"
2922
if [ "$TAG" != "$EXPECTED_TAG" ]; then
3023
echo "Error: Tag $TAG doesn't match expected $EXPECTED_TAG from Cargo.toml" >&2
3124
exit 1
3225
fi
33-
{
34-
echo "tag=$TAG"
35-
} >> "$GITHUB_OUTPUT"
26+
echo "RELEASE_TAG=$TAG" >> "$GITHUB_ENV"
3627
else
37-
{
38-
echo "tag=v$VERSION"
39-
} >> "$GITHUB_OUTPUT"
28+
echo "RELEASE_TAG=v$VERSION" >> "$GITHUB_ENV"
4029
fi
30+
echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_ENV"
4131
4232
- run:
4333
name: Generate checksums
@@ -69,20 +59,20 @@ steps:
6959
curl -fsSL https://docspring.github.io/cigen/install.sh | sh
7060
7161
### Direct downloads
72-
- macOS (Intel): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-macos-amd64.tar.gz
73-
- macOS (Apple Silicon): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-macos-arm64.tar.gz
74-
- Linux (x86_64): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-linux-amd64.tar.gz
75-
- Linux (ARM64): https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}/cigen-linux-arm64.tar.gz
62+
- macOS (Intel): https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/cigen-macos-amd64.tar.gz
63+
- macOS (Apple Silicon): https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/cigen-macos-arm64.tar.gz
64+
- Linux (x86_64): https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/cigen-linux-amd64.tar.gz
65+
- Linux (ARM64): https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/cigen-linux-arm64.tar.gz
7666
EOF
7767
7868
- name: Create GitHub Release
7969
uses: softprops/action-gh-release@v2
8070
with:
81-
tag_name: ${{ steps.version.outputs.tag }}
82-
name: CIGen v${{ steps.version.outputs.version }}
71+
tag_name: ${{ env.RELEASE_TAG }}
72+
name: CIGen v${{ env.RELEASE_VERSION }}
8373
body_path: changelog.md
8474
draft: false
85-
prerelease: ${{ contains(steps.version.outputs.tag, '-') }}
75+
prerelease: ${{ contains(env.RELEASE_TAG, '-') }}
8676
files: |
8777
artifacts/**/*.tar.gz
8878
artifacts/**/*.sha256

0 commit comments

Comments
 (0)