Skip to content

Commit 8d30dd9

Browse files
committed
chore: migrate actions to central repo
1 parent 7c1c70d commit 8d30dd9

3 files changed

Lines changed: 16 additions & 314 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,7 @@ name: CI
22

33
on:
44
pull_request:
5-
branches:
6-
- develop
7-
- main
8-
9-
permissions:
10-
contents: read
11-
12-
env:
13-
CARGO_TERM_COLOR: always
145

156
jobs:
16-
check:
17-
name: Check, Test & Clippy
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v4
21-
22-
- name: Install Rust toolchain
23-
uses: dtolnay/rust-toolchain@stable
24-
25-
- name: Cache cargo registry
26-
uses: actions/cache@v4
27-
with:
28-
path: ~/.cargo/registry
29-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
30-
31-
- name: Cache cargo index
32-
uses: actions/cache@v4
33-
with:
34-
path: ~/.cargo/git
35-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
36-
37-
- name: Cache cargo build
38-
uses: actions/cache@v4
39-
with:
40-
path: target
41-
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
42-
43-
- name: Cargo fmt
44-
run: cargo fmt --check
45-
46-
- name: Cargo build
47-
run: cargo build --release
48-
49-
- name: Cargo test
50-
run: cargo test
51-
52-
- name: Cargo clippy
53-
run: cargo clippy --all-targets -- -D warnings
54-
55-
publish-check:
56-
name: Publish Check (dry-run)
57-
runs-on: ubuntu-latest
58-
steps:
59-
- uses: actions/checkout@v4
60-
61-
- name: Install Rust toolchain
62-
uses: dtolnay/rust-toolchain@stable
63-
64-
- name: Cache cargo registry
65-
uses: actions/cache@v4
66-
with:
67-
path: ~/.cargo/registry
68-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
69-
70-
- name: Cache cargo index
71-
uses: actions/cache@v4
72-
with:
73-
path: ~/.cargo/git
74-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
75-
76-
- name: Cargo publish dry-run
77-
run: cargo publish --dry-run
78-
79-
main-pr-checks:
80-
name: Main PR Requirements
81-
if: github.base_ref == 'main'
82-
runs-on: ubuntu-latest
83-
steps:
84-
- uses: actions/checkout@v4
85-
86-
- name: Check version bump
87-
run: |
88-
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
89-
echo "Version in Cargo.toml: $CURRENT_VERSION"
90-
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
91-
if [ -z "$LAST_TAG" ]; then
92-
echo "✅ First release (no previous tags)"
93-
else
94-
LAST_VERSION=${LAST_TAG#v}
95-
echo "Last tag version: $LAST_VERSION"
96-
if [ "$CURRENT_VERSION" = "$LAST_VERSION" ]; then
97-
echo "❌ Version in Cargo.toml must be bumped for PRs to main"
98-
exit 1
99-
fi
100-
echo "✅ Version bumped correctly"
101-
fi
7+
rust-ci:
8+
uses: UniverLab/workflows/.github/workflows/rust-ci.yml@main

.github/workflows/release.yml

Lines changed: 8 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -2,218 +2,18 @@ name: Release
22

33
on:
44
pull_request:
5-
branches:
6-
- main
7-
types:
8-
- closed
9-
paths:
10-
- Cargo.toml
5+
branches: [main]
6+
types: [closed]
7+
paths: [Cargo.toml]
118
workflow_dispatch:
129

1310
permissions:
1411
contents: write
1512

16-
env:
17-
CARGO_TERM_COLOR: always
18-
1913
jobs:
20-
create-tag:
21-
name: Create Release Tag
14+
release:
2215
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
23-
runs-on: ubuntu-latest
24-
outputs:
25-
tag: ${{ steps.version.outputs.tag }}
26-
version: ${{ steps.version.outputs.version }}
27-
created: ${{ steps.create.outputs.created }}
28-
steps:
29-
- uses: actions/checkout@v4
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Get version from Cargo.toml
34-
id: version
35-
run: |
36-
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/' | tr -d '\r' | xargs)
37-
TAG="v${VERSION}"
38-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
39-
echo "tag=${TAG}" >> $GITHUB_OUTPUT
40-
41-
- name: Check if tag already exists
42-
id: check_tag
43-
run: |
44-
TAG=${{ steps.version.outputs.tag }}
45-
if git rev-parse "$TAG" >/dev/null 2>&1; then
46-
echo "exists=true" >> $GITHUB_OUTPUT
47-
echo "Tag $TAG already exists, skipping"
48-
else
49-
echo "exists=false" >> $GITHUB_OUTPUT
50-
fi
51-
52-
- name: Create and push tag
53-
id: create
54-
run: |
55-
if [ "${{ steps.check_tag.outputs.exists }}" = "true" ]; then
56-
echo "created=false" >> $GITHUB_OUTPUT
57-
echo "Tag already exists — skipping release"
58-
exit 0
59-
fi
60-
TAG=${{ steps.version.outputs.tag }}
61-
git config user.name "github-actions[bot]"
62-
git config user.email "github-actions[bot]@users.noreply.github.com"
63-
git tag -a "$TAG" -m "Release $TAG"
64-
git push origin "$TAG"
65-
echo "created=true" >> $GITHUB_OUTPUT
66-
echo "Tag $TAG created and pushed"
67-
68-
build:
69-
name: Build ${{ matrix.target }}
70-
needs: create-tag
71-
if: needs.create-tag.outputs.created == 'true'
72-
runs-on: ${{ matrix.os }}
73-
strategy:
74-
fail-fast: false
75-
matrix:
76-
include:
77-
- target: x86_64-unknown-linux-musl
78-
os: ubuntu-latest
79-
archive: tar.gz
80-
- target: aarch64-apple-darwin
81-
os: macos-latest
82-
archive: tar.gz
83-
- target: x86_64-apple-darwin
84-
os: macos-latest
85-
archive: tar.gz
86-
- target: x86_64-pc-windows-msvc
87-
os: windows-latest
88-
archive: zip
89-
90-
steps:
91-
- uses: actions/checkout@v4
92-
with:
93-
ref: ${{ needs.create-tag.outputs.tag }}
94-
95-
- name: Install Rust toolchain
96-
uses: dtolnay/rust-toolchain@stable
97-
with:
98-
targets: ${{ matrix.target }}
99-
100-
- name: Install musl tools (Linux)
101-
if: matrix.target == 'x86_64-unknown-linux-musl'
102-
run: sudo apt-get update && sudo apt-get install -y musl-tools
103-
104-
- name: Build release binary
105-
run: cargo build --release --target ${{ matrix.target }}
106-
107-
- name: Package (unix)
108-
if: matrix.archive == 'tar.gz'
109-
run: |
110-
cd target/${{ matrix.target }}/release
111-
tar czf "../../../gitkit-${{ needs.create-tag.outputs.tag }}-${{ matrix.target }}.tar.gz" gitkit
112-
cd ../../..
113-
114-
- name: Package (windows)
115-
if: matrix.archive == 'zip'
116-
shell: pwsh
117-
run: |
118-
cd target/${{ matrix.target }}/release
119-
Compress-Archive -Path gitkit.exe -DestinationPath "../../../gitkit-${{ needs.create-tag.outputs.tag }}-${{ matrix.target }}.zip"
120-
cd ../../..
121-
122-
- name: Upload artifact
123-
uses: actions/upload-artifact@v4
124-
with:
125-
name: gitkit-${{ matrix.target }}
126-
path: gitkit-${{ needs.create-tag.outputs.tag }}-${{ matrix.target }}.*
127-
128-
github-release:
129-
name: Create GitHub Release
130-
needs: [create-tag, build]
131-
runs-on: ubuntu-latest
132-
steps:
133-
- uses: actions/checkout@v4
134-
135-
- name: Download all artifacts
136-
uses: actions/download-artifact@v4
137-
with:
138-
path: artifacts
139-
merge-multiple: true
140-
141-
- name: Create release
142-
uses: softprops/action-gh-release@v2
143-
with:
144-
tag_name: ${{ needs.create-tag.outputs.tag }}
145-
generate_release_notes: true
146-
files: artifacts/*
147-
148-
approve:
149-
name: Awaiting Manual Approval
150-
needs: github-release
151-
runs-on: ubuntu-latest
152-
environment:
153-
name: production
154-
steps:
155-
- name: Approval granted
156-
run: echo "Release approved for publishing to crates.io"
157-
158-
ensure-owners:
159-
name: Ensure crates.io owners
160-
needs: create-tag
161-
if: needs.create-tag.outputs.created == 'true'
162-
runs-on: ubuntu-latest
163-
steps:
164-
- uses: actions/checkout@v4
165-
with:
166-
ref: ${{ needs.create-tag.outputs.tag }}
167-
- name: Install Rust toolchain
168-
uses: dtolnay/rust-toolchain@stable
169-
170-
- name: Add crates.io owners (best-effort)
171-
env:
172-
TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
173-
OWNERS: github:univerlab:owners
174-
run: |
175-
set -eu
176-
if [ -z "$TOKEN" ]; then
177-
echo "No cargo token found in CARGO_REGISTRY_TOKEN; skipping owners update"
178-
exit 0
179-
fi
180-
CRATE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | tr -d '\r')
181-
echo "crate=$CRATE_NAME"
182-
for owner in $(echo "$OWNERS" | tr ',' ' '); do
183-
echo "Adding owner: $owner"
184-
cargo owner --token "$TOKEN" --add "$owner" || echo "cargo owner failed for $owner (continuing)"
185-
done
186-
187-
publish:
188-
name: Publish to crates.io
189-
needs: [create-tag, approve, ensure-owners]
190-
runs-on: ubuntu-latest
191-
steps:
192-
- uses: actions/checkout@v4
193-
with:
194-
ref: ${{ needs.create-tag.outputs.tag }}
195-
196-
- name: Install Rust toolchain
197-
uses: dtolnay/rust-toolchain@stable
198-
199-
- name: Check if stable release
200-
id: version_check
201-
run: |
202-
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | xargs)
203-
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
204-
echo "is_stable=true" >> $GITHUB_OUTPUT
205-
echo "Version $VERSION is stable — will publish"
206-
else
207-
echo "is_stable=false" >> $GITHUB_OUTPUT
208-
echo "Version $VERSION is prerelease/dev — skipping publish"
209-
fi
210-
211-
- name: Cargo publish
212-
if: steps.version_check.outputs.is_stable == 'true'
213-
env:
214-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
215-
run: cargo publish --allow-dirty
216-
217-
- name: Skipped prerelease
218-
if: steps.version_check.outputs.is_stable == 'false'
219-
run: echo "⏭️ Skipped crates.io publish for prerelease version"
16+
uses: UniverLab/workflows/.github/workflows/rust-release.yml@main
17+
with:
18+
binary-name: gitkit
19+
secrets: inherit

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
░░░░░░
1313
```
1414

15-
[![CI](https://github.com/UniverLab/gitkit/actions/workflows/ci.yml/badge.svg)](https://github.com/UniverLab/gitkit/actions/workflows/ci.yml)
16-
[![Release](https://github.com/UniverLab/gitkit/actions/workflows/release.yml/badge.svg)](https://github.com/UniverLab/gitkit/actions/workflows/release.yml)
17-
[![Crates.io](https://img.shields.io/crates/v/gitkit)](https://crates.io/crates/gitkit)
18-
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
15+
<p align="center">
16+
<a href="https://github.com/UniverLab/gitkit/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/UniverLab/gitkit/ci.yml?branch=main&style=for-the-badge&label=CI" alt="CI"/></a>
17+
<a href="https://crates.io/crates/gitkit"><img src="https://img.shields.io/crates/v/gitkit?style=for-the-badge&logo=rust&logoColor=white" alt="Crates.io"/></a>
18+
<img src="https://img.shields.io/badge/Status-Active-27AE60?style=for-the-badge" alt="Status"/>
19+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-2E8B57?style=for-the-badge" alt="License"/></a>
20+
</p>
1921

2022
Set up a git repo the way you actually work — one guided flow for hooks, `.gitignore`, `.gitattributes`, and git config. One binary, no Node.js, no Python, no runtime dependencies.
2123

@@ -223,13 +225,6 @@ Built-ins are embedded in the binary — no network required.
223225

224226
MIT
225227

226-
---
227-
## Support
228-
229-
- 📖 [GitHub Issues](https://github.com/UniverLab/gitkit/issues) — Report bugs or request features
230-
- 💬 [Discussions](https://github.com/UniverLab/gitkit/discussions) — Ask questions
231-
- 🐦 Twitter: [@JheisonMB](https://twitter.com/JheisonMB)
232-
233228
---
234229

235230
Made with ❤️ by [JheisonMB](https://github.com/JheisonMB) and [UniverLab](https://github.com/UniverLab)

0 commit comments

Comments
 (0)