Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 4 additions & 97 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,103 +1,10 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:
branches:
- develop
- main

permissions:
contents: read
pull-requests: write

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check, Test & Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Cargo fmt
run: cargo fmt --check

- name: Cargo build
run: cargo build --release

- name: Cargo test
run: cargo test

- name: Cargo clippy
run: cargo clippy --all-targets -- -D warnings

publish-check:
name: Publish Check (dry-run)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cargo publish dry-run
run: cargo publish --dry-run

main-pr-checks:
name: Main PR Requirements
if: github.base_ref == 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check version bump
run: |
CURRENT_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "Versión en Cargo.toml: $CURRENT_VERSION"

LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
echo "✅ Primer release (no hay tags previos)"
else
LAST_VERSION=${LAST_TAG#v}
echo "Última versión en tag: $LAST_VERSION"
if [ "$CURRENT_VERSION" = "$LAST_VERSION" ]; then
echo "❌ Error: La versión en Cargo.toml debe bumpearse en PR a main"
exit 1
fi
echo "✅ Versión bumpeada correctamente"
fi
rust-ci:
uses: UniverLab/workflows/.github/workflows/rust-ci.yml@main
220 changes: 8 additions & 212 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,219 +2,15 @@ name: Release

on:
pull_request:
branches:
- main
types:
- closed
paths:
- Cargo.toml
branches: [main]
types: [closed]
paths: [Cargo.toml]
workflow_dispatch:

permissions:
contents: write

env:
CARGO_TERM_COLOR: always

jobs:
create-tag:
name: Create Release Tag
release:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
created: ${{ steps.create.outputs.created }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get version from Cargo.toml
id: version
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/' | tr -d '\r' | xargs)
TAG="v${VERSION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT

- name: Check if tag already exists
id: check_tag
run: |
TAG=${{ steps.version.outputs.tag }}
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag $TAG already exists, skipping"
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Create and push tag
id: create
run: |
if [ "${{ steps.check_tag.outputs.exists }}" = "true" ]; then
echo "created=false" >> $GITHUB_OUTPUT
echo "Tag already exists — skipping release"
exit 0
fi
TAG=${{ steps.version.outputs.tag }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
echo "created=true" >> $GITHUB_OUTPUT
echo "Tag $TAG created and pushed"

build:
name: Build ${{ matrix.target }}
needs: create-tag
if: needs.create-tag.outputs.created == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip

steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-tag.outputs.tag }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install musl tools (Linux)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools

- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}

- name: Package (unix)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar czf "../../../ghscaff-${{ needs.create-tag.outputs.tag }}-${{ matrix.target }}.tar.gz" ghscaff
cd ../../..

- name: Package (windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path ghscaff.exe -DestinationPath "../../../ghscaff-${{ needs.create-tag.outputs.tag }}-${{ matrix.target }}.zip"
cd ../../..

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ghscaff-${{ matrix.target }}
path: ghscaff-${{ needs.create-tag.outputs.tag }}-${{ matrix.target }}.*

github-release:
name: Create GitHub Release
needs: [create-tag, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true

- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.create-tag.outputs.tag }}
generate_release_notes: true
files: artifacts/*

approve:
name: Awaiting Manual Approval
needs: github-release
runs-on: ubuntu-latest
environment:
name: production
steps:
- name: Approval granted
run: echo "Release approved for publishing to crates.io"

ensure-owners:
name: Ensure crates.io owners
needs: create-tag
if: needs.create-tag.outputs.created == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-tag.outputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Add crates.io owners (best-effort)
env:
TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
OWNERS: github:univerlab:owners
run: |
set -eu
if [ -z "$TOKEN" ]; then
echo "No cargo token found in CARGO_REGISTRY_TOKEN; skipping owners update"
exit 0
fi
CRATE_NAME=$(grep '^name = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | tr -d '\r')
echo "crate=$CRATE_NAME"
for owner in $(echo "$OWNERS" | tr ',' ' '); do
echo "Adding owner: $owner"
if command -v cargo >/dev/null 2>&1; then
cargo owner --token "$TOKEN" --add "$owner" || echo "cargo owner failed for $owner (continuing)"
else
curl -sSf -X PUT -H "Authorization: Token $TOKEN" -H "Content-Type: application/json" \
-d "{\"users\":[\"$owner\"]}" "https://crates.io/api/v1/crates/$CRATE_NAME/owners" || echo "API add failed for $owner (continuing)"
fi
done

publish:
name: Publish to crates.io
needs: [create-tag, approve, ensure-owners]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-tag.outputs.tag }}

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Check if stable release
id: version_check
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | xargs)
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_stable=true" >> $GITHUB_OUTPUT
echo "Version $VERSION is stable — will publish"
else
echo "is_stable=false" >> $GITHUB_OUTPUT
echo "Version $VERSION is prerelease/dev — skipping publish"
fi

- name: Cargo publish
if: steps.version_check.outputs.is_stable == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --allow-dirty
uses: UniverLab/workflows/.github/workflows/rust-release.yml@main
with:
binary-name: ghscaff
secrets: inherit
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ghscaff"
version = "0.3.1"
version = "0.3.2"
edition = "2021"
description = "Interactive CLI wizard for creating and configuring GitHub repositories"
license = "MIT"
Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
░░░░░░
```

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

Interactive CLI wizard for creating and configuring GitHub repositories. One binary, zero runtime dependencies.

Expand Down Expand Up @@ -257,12 +260,4 @@ MIT — see [LICENSE](LICENSE) for details.

---

## Support

- 📖 [GitHub Issues](https://github.com/UniverLab/ghscaff/issues) — Report bugs or request features
- 💬 [Discussions](https://github.com/UniverLab/ghscaff/discussions) — Ask questions
- 🐦 Twitter: [@JheisonMB](https://twitter.com/JheisonMB)

---

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