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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

# Cache Docker layers for faster subsequent builds
- name: Cache Docker layers
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/ecosystem-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Ecosystem Release

on:
push:
tags:
- "ecosystem/*/v*.*.*" # ecosystem/solana-spl-token/v3.4.0

env:
CARGO_TERM_COLOR: always

jobs:
# Extract ecosystem info from tag
setup:
name: Setup Release Info
runs-on: ubuntu-latest
outputs:
ecosystem_name: ${{ steps.parse.outputs.ecosystem_name }}
package_name: ${{ steps.parse.outputs.package_name }}
version: ${{ steps.parse.outputs.version }}
manifest_path: ${{ steps.parse.outputs.manifest_path }}
steps:
- uses: actions/checkout@v4
- name: Parse ecosystem tag
id: parse
run: |
# Use make to parse the tag
eval $(make parse-ecosystem-tag TAG="${GITHUB_REF#refs/tags/}")

# Set GitHub outputs
echo "ecosystem_name=$ECOSYSTEM_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "manifest_path=$MANIFEST_PATH" >> $GITHUB_OUTPUT

# Validate ecosystem package
validate:
name: Ecosystem Validation
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

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

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

- name: Install Solana CLI
run: make install-solana

- name: Validate ecosystem package
run: make validate-ecosystem-package MANIFEST_PATH="${{ needs.setup.outputs.manifest_path }}" VERSION="${{ needs.setup.outputs.version }}"
env:
PATH: ${{ env.PATH }}:$HOME/.local/share/solana/install/active_release/bin

# Publish to crates.io
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [setup, validate]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

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

- name: Install Solana CLI
run: make install-solana

- name: Publish ecosystem package
run: make publish-ecosystem-package MANIFEST_PATH="${{ needs.setup.outputs.manifest_path }}"
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
PATH: ${{ env.PATH }}:$HOME/.local/share/solana/install/active_release/bin

# Create GitHub release
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [setup, publish]
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Create GitHub Release
run: |
make create-ecosystem-github-release \
ECOSYSTEM_NAME="${{ needs.setup.outputs.ecosystem_name }}" \
PACKAGE_NAME="${{ needs.setup.outputs.package_name }}" \
VERSION="${{ needs.setup.outputs.version }}" \
TAG="${GITHUB_REF#refs/tags/}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- run: TAG_VERSION="${GITHUB_REF#refs/tags/v}" make release-validation

# Publish to crates.io
Expand All @@ -24,6 +26,8 @@ jobs:
needs: validate
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- run: make publish
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ecosystem/solana-spl-token/upstream"]
path = ecosystem/solana-spl-token/upstream
url = https://github.com/solana-program/token
65 changes: 7 additions & 58 deletions Cargo.lock

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

13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[workspace]
members = [ #
".",
"ecosystem/solana-spl-token",
]

[package]
name = "elf-magic"
version = "0.3.1"
Expand All @@ -10,7 +16,6 @@ documentation = "https://github.com/levicook/elf-magic"
readme = "README.md"
keywords = ["workspace-automation", "cargo", "elf", "build-tool", "solana"]
authors = ["Levi Cook <levicook@gmail.com>"]
license-file = "LICENSE"

[dependencies]
anyhow = "1.0"
Expand All @@ -22,10 +27,4 @@ toml = "0.8"
minijinja = "2.10.2"
chrono = { version = "0.4", features = ["serde"] }
tempfile = "3.0"
temp-env = { version = "0.3", optional = true }
cargo_metadata = "0.20"

[features]
testing = ["dep:temp-env"]

[dev-dependencies]
90 changes: 84 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ci:
$(MAKE) test
@echo "All binaries clippy:"
cargo clippy --all-targets --all-features -- -D warnings
@echo "Publish dry run:"
cargo publish --dry-run --allow-dirty
@echo "Core package publish dry run:"
cargo publish --package elf-magic --dry-run --allow-dirty
@echo "✅ CI passed"

# Release validation - comprehensive checks before publishing
Expand All @@ -33,9 +33,9 @@ release-validation:
# Publish to crates.io (requires CARGO_REGISTRY_TOKEN)
.PHONY: publish
publish:
@echo "📦 Publishing to crates.io..."
cargo publish --token $$CARGO_REGISTRY_TOKEN
@echo "✅ Published to crates.io"
@echo "📦 Publishing core elf-magic package to crates.io..."
cargo publish --package elf-magic --token $$CARGO_REGISTRY_TOKEN
@echo "✅ Published elf-magic to crates.io"

# Dogfooding - Use our own tool for releases! 🎯
.PHONY: release-patch release-minor release-major
Expand All @@ -48,6 +48,73 @@ release-minor:
release-major:
@./scripts/release.sh major

# Ecosystem package releases (maintainer-controlled + GitHub validation)
.PHONY: ecosystem-list validate-ecosystem-package publish-ecosystem-package parse-ecosystem-tag install-solana create-ecosystem-github-release

ecosystem-list:
@echo "📦 Available ecosystem packages:"
@find ecosystem -maxdepth 1 -type d -not -name ecosystem | sed 's|ecosystem/| - |' | sort

# Validate ecosystem package (used by CI)
validate-ecosystem-package:
@if [ -z "$(MANIFEST_PATH)" ]; then \
echo "❌ MANIFEST_PATH required (e.g., ecosystem/solana-spl-token/Cargo.toml)"; \
exit 1; \
fi
@if [ -n "$(VERSION)" ]; then \
echo "🔍 Verifying tag version matches Cargo.toml..."; \
CARGO_VERSION=$$(grep '^version = ' "$(MANIFEST_PATH)" | sed 's/version = "\(.*\)"/\1/'); \
if [ "$(VERSION)" != "$$CARGO_VERSION" ]; then \
echo "❌ Tag version $(VERSION) doesn't match Cargo.toml version $$CARGO_VERSION"; \
exit 1; \
fi; \
echo "✅ Tag version matches Cargo.toml version: $(VERSION)"; \
fi
@echo "🔨 Building ecosystem package..."
cargo build --manifest-path "$(MANIFEST_PATH)"
@echo "🧪 Running tests (includes ELF validation)..."
cargo test --manifest-path "$(MANIFEST_PATH)"
@echo "📎 Running clippy..."
cargo clippy --manifest-path "$(MANIFEST_PATH)" --all-targets -- -D warnings
@echo "📦 Publish dry run..."
cargo publish --manifest-path "$(MANIFEST_PATH)" --dry-run
@echo "✅ Ecosystem package validation passed"

# Publish ecosystem package to crates.io (used by CI)
publish-ecosystem-package:
@if [ -z "$(MANIFEST_PATH)" ] || [ -z "$(CARGO_REGISTRY_TOKEN)" ]; then \
echo "❌ MANIFEST_PATH and CARGO_REGISTRY_TOKEN required"; \
exit 1; \
fi
@echo "🔨 Building ecosystem package for publication..."
cargo build --manifest-path "$(MANIFEST_PATH)"
@echo "📦 Publishing to crates.io..."
cargo publish --manifest-path "$(MANIFEST_PATH)" --token "$(CARGO_REGISTRY_TOKEN)"
@echo "✅ Published to crates.io!"


# Parse ecosystem tag (used by CI)
parse-ecosystem-tag:
@if [ -z "$(TAG)" ]; then \
echo "❌ TAG required"; \
echo " Example: make parse-ecosystem-tag TAG=ecosystem/solana-spl-token/v3.4.0"; \
exit 1; \
fi
@./scripts/ci/parse-tag "$(TAG)"

# Install Solana CLI (used by CI)
install-solana:
@./scripts/ci/install-solana

# Create ecosystem GitHub release (used by CI)
create-ecosystem-github-release:
@if [ -z "$(ECOSYSTEM_NAME)" ] || [ -z "$(PACKAGE_NAME)" ] || [ -z "$(VERSION)" ] || [ -z "$(TAG)" ]; then \
echo "❌ ECOSYSTEM_NAME, PACKAGE_NAME, VERSION, and TAG required"; \
echo " Example: make create-ecosystem-github-release ECOSYSTEM_NAME=solana-spl-token PACKAGE_NAME=elf-magic-solana-spl-token VERSION=3.4.0 TAG=ecosystem/solana-spl-token/v3.4.0"; \
exit 1; \
fi
@./scripts/ci/create-github-release "$(ECOSYSTEM_NAME)" "$(PACKAGE_NAME)" "$(VERSION)" "$(TAG)"

# =============================================================================
# Testing
# =============================================================================
Expand Down Expand Up @@ -110,7 +177,18 @@ help:
@echo " make release-major Release major version (breaking changes)"
@echo " make release-minor Release minor version (new features)"
@echo " make release-patch Release patch version (bug fixes)"
@echo " make release-validation Complete release validation"
@echo " make release-validation Complete release validation"
@echo ""
@echo "Ecosystem:"
@echo " make ecosystem-list List available ecosystem packages"
@echo ""
@echo "Ecosystem CI:"
@echo " make create-ecosystem-github-release ECOSYSTEM_NAME=<name> PACKAGE_NAME=<name> VERSION=<version> TAG=<tag>"
@echo " make install-solana Install Solana CLI"
@echo " make parse-ecosystem-tag TAG=<tag> Parse ecosystem release tag"

@echo " make publish-ecosystem-package MANIFEST_PATH=<path> Publish ecosystem package"
@echo " make validate-ecosystem-package MANIFEST_PATH=<path> Validate ecosystem package"
@echo ""
@echo "Development:"
@echo " make check Check code without building"
Expand Down
Loading