feat: (version) bumped version to 0.1.42 #83
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - v[0-9]+.[0-9]+.[0-9]+ | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish-cargo: | |
| name: Publish to Cargo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Publish to crates.io | |
| run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| publish-binaries: | |
| name: Publish binaries | |
| runs-on: ${{ matrix.build.OS }} | |
| needs: publish-cargo | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| build: | |
| - { NAME: linux-x64-glibc, OS: ubuntu-22.04, TOOLCHAIN: stable, TARGET: x86_64-unknown-linux-gnu, NPM_PUBLISH: true, PYPI_PUBLISH: true } | |
| - { NAME: linux-x64-musl, OS: ubuntu-22.04, TOOLCHAIN: stable, TARGET: x86_64-unknown-linux-musl, NPM_PUBLISH: false, PYPI_PUBLISH: true } | |
| - { NAME: linux-x86-glibc, OS: ubuntu-22.04, TOOLCHAIN: stable, TARGET: i686-unknown-linux-gnu, NPM_PUBLISH: false, PYPI_PUBLISH: false } | |
| - { NAME: linux-x86-musl, OS: ubuntu-22.04, TOOLCHAIN: stable, TARGET: i686-unknown-linux-musl, NPM_PUBLISH: false, PYPI_PUBLISH: true } | |
| - { NAME: linux-arm64-glibc, OS: ubuntu-22.04, TOOLCHAIN: stable, TARGET: aarch64-unknown-linux-gnu, NPM_PUBLISH: true, PYPI_PUBLISH: true } | |
| - { NAME: linux-arm64-musl, OS: ubuntu-22.04, TOOLCHAIN: stable, TARGET: aarch64-unknown-linux-musl, NPM_PUBLISH: false, PYPI_PUBLISH: true } | |
| - { NAME: win32-x64-msvc, OS: windows-latest, TOOLCHAIN: stable, TARGET: x86_64-pc-windows-msvc, NPM_PUBLISH: true, PYPI_PUBLISH: true } | |
| - { NAME: win32-x86-msvc, OS: windows-latest, TOOLCHAIN: stable, TARGET: i686-pc-windows-msvc, NPM_PUBLISH: false, PYPI_PUBLISH: true } | |
| - { NAME: win32-arm64-msvc, OS: windows-latest, TOOLCHAIN: stable, TARGET: aarch64-pc-windows-msvc, NPM_PUBLISH: true, PYPI_PUBLISH: false } | |
| - { NAME: darwin-x64, OS: macos-15, TOOLCHAIN: stable, TARGET: x86_64-apple-darwin, NPM_PUBLISH: true, PYPI_PUBLISH: true } | |
| - { NAME: darwin-arm64, OS: macos-15, TOOLCHAIN: stable, TARGET: aarch64-apple-darwin, NPM_PUBLISH: true, PYPI_PUBLISH: true } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: ${{ matrix.build.TOOLCHAIN }} | |
| target: ${{ matrix.build.TARGET }} | |
| - name: Install cross | |
| if: runner.os == 'Linux' | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Set release version | |
| shell: bash | |
| run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Build (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//') | |
| # Build | |
| if [[ "${{ runner.os }}" == "Linux" ]]; then | |
| cross build --release --target ${{ matrix.build.TARGET }} | |
| else | |
| cargo build --release --target ${{ matrix.build.TARGET }} | |
| fi | |
| # Prepare binary with unique name | |
| if [[ "${{ matrix.build.TARGET }}" == *"windows"* ]]; then | |
| BINARY="gh-templates-${{ matrix.build.NAME }}.exe" | |
| cp target/${{ matrix.build.TARGET }}/release/gh-templates.exe $BINARY | |
| else | |
| BINARY="gh-templates-${{ matrix.build.NAME }}" | |
| cp target/${{ matrix.build.TARGET }}/release/gh-templates $BINARY | |
| chmod +x $BINARY | |
| fi | |
| echo "BINARY=$BINARY" >> $GITHUB_ENV | |
| # Prepare npm + python packages | |
| mkdir -p npm/bin python/gh_templates_bin | |
| # For npm, copy the platform-specific binary but also create a generic named version | |
| cp $BINARY npm/bin/ | |
| if [[ "${{ matrix.build.TARGET }}" == *"windows"* ]]; then | |
| cp $BINARY npm/bin/gh-templates.exe | |
| else | |
| cp $BINARY npm/bin/gh-templates | |
| fi | |
| # For python, use the generic name since the wrapper handles execution | |
| if [[ "${{ matrix.build.TARGET }}" == *"windows"* ]]; then | |
| cp $BINARY python/gh_templates_bin/gh-templates.exe | |
| else | |
| cp $BINARY python/gh_templates_bin/gh-templates | |
| fi | |
| # npm package.json - reference generic binary name | |
| cat > npm/package.json << EOF | |
| { | |
| "name": "@rafaeljohn9/gh-templates-${{ matrix.build.NAME }}", | |
| "version": "$VERSION", | |
| "bin": { | |
| "gh-templates": "./bin/gh-templates$([[ "${{ matrix.build.TARGET }}" == *"windows"* ]] && echo ".exe" || echo "")" | |
| }, | |
| "files": ["bin/"], | |
| "license": "APACHE-2.0" | |
| } | |
| EOF | |
| # Python setup.py | |
| cat > python/setup.py << EOF | |
| from setuptools import setup | |
| setup( | |
| name='gh-templates-${{ matrix.build.NAME }}', | |
| version='$VERSION', | |
| packages=['gh_templates_bin'], | |
| package_data={'gh_templates_bin': ['*']}, | |
| entry_points={'console_scripts': ['gh-templates=gh_templates_bin:main']}, | |
| license='APACHE-2.0' | |
| ) | |
| EOF | |
| # Python __init__.py | |
| cat > python/gh_templates_bin/__init__.py << 'EOF' | |
| import os, sys, subprocess | |
| def main(): | |
| binary = os.path.join(os.path.dirname(__file__), os.getenv("BINARY", "gh-templates")) | |
| sys.exit(subprocess.run([binary] + sys.argv[1:]).returncode) | |
| EOF | |
| - name: Upload to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ env.BINARY }} | |
| overwrite: true | |
| fail_on_unmatched_files: false | |
| # (rest of your npm + PyPI steps remain unchanged below …) | |
| - name: Setup Node.js for NPM | |
| if: matrix.build.NPM_PUBLISH == true | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Publish platform-specific NPM package | |
| if: matrix.build.NPM_PUBLISH == true | |
| shell: bash | |
| run: | | |
| # Create platform-specific package directory | |
| BINARY="gh-templates" | |
| NODE_OS=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1) | |
| NODE_ARCH=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2) | |
| if [ "${{ runner.os }}" = "Windows" ]; then | |
| BINARY="${BINARY}.exe" | |
| NPM_PKG="gh-templates-windows-${NODE_ARCH}" | |
| else | |
| NPM_PKG="gh-templates-${NODE_OS}-${NODE_ARCH}" | |
| fi | |
| mkdir -p "${NPM_PKG}/bin" | |
| cp "${BINARY}" "${NPM_PKG}/bin/" | |
| cp README.md "${NPM_PKG}/" || echo "README.md not found, skipping" | |
| # Create package.json for platform-specific package | |
| cat > "${NPM_PKG}/package.json" << EOF | |
| { | |
| "name": "${NPM_PKG}", | |
| "version": "${{ env.RELEASE_VERSION }}", | |
| "description": "GitHub Templates CLI tool - ${NODE_OS} ${NODE_ARCH}", | |
| "bin": { | |
| "gh-templates": "./bin/${BINARY}" | |
| }, | |
| "files": ["bin/"], | |
| "license": "Apache-2.0", | |
| "repository": { | |
| "type": "git", | |
| "url": "git+https://github.com/${{ github.repository }}.git" | |
| }, | |
| "os": ["${NODE_OS}"], | |
| "cpu": ["${NODE_ARCH}"] | |
| } | |
| EOF | |
| cd "${NPM_PKG}" | |
| npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Build Python wheels (Linux) | |
| if: matrix.build.PYPI_PUBLISH == true && runner.os == 'Linux' | |
| run: | | |
| # Create wheel directory structure | |
| mkdir -p python/gh_templates_bin | |
| cp gh-templates python/gh_templates_bin/ | |
| # Create setup.py | |
| cat > python/setup.py << EOF | |
| from setuptools import setup, find_packages | |
| import platform | |
| setup( | |
| name='gh-templates-${{ matrix.build.NAME }}', | |
| version='${{ env.RELEASE_VERSION }}', | |
| description='GitHub Templates CLI tool', | |
| packages=find_packages(), | |
| package_data={'gh_templates_bin': ['*']}, | |
| entry_points={'console_scripts': ['gh-templates=gh_templates_bin:main']}, | |
| license='Apache-2.0', | |
| classifiers=[ | |
| 'Development Status :: 4 - Beta', | |
| 'Intended Audience :: Developers', | |
| 'License :: OSI Approved :: Apache Software License', | |
| 'Programming Language :: Python :: 3', | |
| 'Programming Language :: Python :: 3.7', | |
| 'Programming Language :: Python :: 3.8', | |
| 'Programming Language :: Python :: 3.9', | |
| 'Programming Language :: Python :: 3.10', | |
| 'Programming Language :: Python :: 3.11', | |
| 'Programming Language :: Python :: 3.12', | |
| ], | |
| python_requires='>=3.7', | |
| ) | |
| EOF | |
| # Create __init__.py | |
| cat > python/gh_templates_bin/__init__.py << 'EOF' | |
| import os, sys, subprocess, stat | |
| def main(): | |
| binary = os.path.join(os.path.dirname(__file__), 'gh-templates') | |
| if not os.path.exists(binary): | |
| print(f"Error: Binary not found at {binary}") | |
| sys.exit(1) | |
| # Ensure binary is executable | |
| os.chmod(binary, os.stat(binary).st_mode | stat.S_IEXEC) | |
| sys.exit(subprocess.run([binary] + sys.argv[1:]).returncode) | |
| EOF | |
| - name: Build Python wheels (macOS) | |
| if: matrix.build.PYPI_PUBLISH == true && runner.os == 'macOS' | |
| run: | | |
| # Create wheel directory structure | |
| mkdir -p python/gh_templates_bin | |
| cp gh-templates python/gh_templates_bin/ | |
| # Create setup.py | |
| cat > python/setup.py << EOF | |
| from setuptools import setup, find_packages | |
| setup( | |
| name='gh-templates-${{ matrix.build.NAME }}', | |
| version='${{ env.RELEASE_VERSION }}', | |
| description='GitHub Templates CLI tool', | |
| packages=find_packages(), | |
| package_data={'gh_templates_bin': ['*']}, | |
| entry_points={'console_scripts': ['gh-templates=gh_templates_bin:main']}, | |
| license='Apache-2.0', | |
| classifiers=[ | |
| 'Development Status :: 4 - Beta', | |
| 'Intended Audience :: Developers', | |
| 'License :: OSI Approved :: Apache Software License', | |
| 'Programming Language :: Python :: 3', | |
| 'Programming Language :: Python :: 3.7', | |
| 'Programming Language :: Python :: 3.8', | |
| 'Programming Language :: Python :: 3.9', | |
| 'Programming Language :: Python :: 3.10', | |
| 'Programming Language :: Python :: 3.11', | |
| 'Programming Language :: Python :: 3.12', | |
| ], | |
| python_requires='>=3.7', | |
| ) | |
| EOF | |
| # Create __init__.py | |
| cat > python/gh_templates_bin/__init__.py << 'EOF' | |
| import os, sys, subprocess, stat | |
| def main(): | |
| binary = os.path.join(os.path.dirname(__file__), 'gh-templates') | |
| if not os.path.exists(binary): | |
| print(f"Error: Binary not found at {binary}") | |
| sys.exit(1) | |
| # Ensure binary is executable | |
| os.chmod(binary, os.stat(binary).st_mode | stat.S_IEXEC) | |
| sys.exit(subprocess.run([binary] + sys.argv[1:]).returncode) | |
| EOF | |
| - name: Build Python wheels (Windows) | |
| if: matrix.build.PYPI_PUBLISH == true && runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| # Create wheel directory structure | |
| New-Item -ItemType Directory -Force -Path python/gh_templates_bin | |
| Copy-Item gh-templates.exe python/gh_templates_bin/ | |
| # Create setup.py | |
| @" | |
| from setuptools import setup, find_packages | |
| setup( | |
| name='gh-templates-${{ matrix.build.NAME }}', | |
| version='${{ env.RELEASE_VERSION }}', | |
| description='GitHub Templates CLI tool', | |
| packages=find_packages(), | |
| package_data={'gh_templates_bin': ['*']}, | |
| entry_points={'console_scripts': ['gh-templates=gh_templates_bin:main']}, | |
| license='Apache-2.0', | |
| classifiers=[ | |
| 'Development Status :: 4 - Beta', | |
| 'Intended Audience :: Developers', | |
| 'License :: OSI Approved :: Apache Software License', | |
| 'Programming Language :: Python :: 3', | |
| 'Programming Language :: Python :: 3.7', | |
| 'Programming Language :: Python :: 3.8', | |
| 'Programming Language :: Python :: 3.9', | |
| 'Programming Language :: Python :: 3.10', | |
| 'Programming Language :: Python :: 3.11', | |
| 'Programming Language :: Python :: 3.12', | |
| ], | |
| python_requires='>=3.7', | |
| ) | |
| "@ | Out-File -FilePath python/setup.py -Encoding UTF8 | |
| # Create __init__.py | |
| @' | |
| import os, sys, subprocess | |
| def main(): | |
| binary = os.path.join(os.path.dirname(__file__), 'gh-templates.exe') | |
| if not os.path.exists(binary): | |
| print(f"Error: Binary not found at {binary}") | |
| sys.exit(1) | |
| sys.exit(subprocess.run([binary] + sys.argv[1:]).returncode) | |
| '@ | Out-File -FilePath python/gh_templates_bin/__init__.py -Encoding UTF8 | |
| - name: Setup Python for PyPI | |
| if: matrix.build.PYPI_PUBLISH == true | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Publish to PyPI | |
| if: matrix.build.PYPI_PUBLISH == true | |
| shell: bash | |
| run: | | |
| cd python | |
| # Install required dependencies | |
| python -m pip install --upgrade pip setuptools wheel twine | |
| # Build the package | |
| python setup.py sdist bdist_wheel | |
| # Upload to PyPI | |
| python -m twine upload dist/* --skip-existing -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} | |
| publish-python-unified: | |
| name: Publish unified Python package | |
| runs-on: ubuntu-latest | |
| needs: publish-binaries | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Set release version | |
| run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Create unified Python package | |
| run: | | |
| mkdir -p python-unified/gh_templates | |
| # Create setup.py for unified package | |
| cat > python-unified/setup.py << 'EOF' | |
| import platform | |
| from setuptools import setup, find_packages | |
| import os | |
| # Get version from environment | |
| version = os.environ.get('RELEASE_VERSION', '0.0.0') | |
| # Determine the correct platform-specific package | |
| def get_platform_package(): | |
| system = platform.system().lower() | |
| machine = platform.machine().lower() | |
| # Normalize architecture names | |
| if machine in ['x86_64', 'amd64']: | |
| arch = 'x64' | |
| elif machine in ['aarch64', 'arm64']: | |
| arch = 'arm64' | |
| elif machine in ['i386', 'i686']: | |
| arch = 'x86' | |
| else: | |
| arch = machine | |
| # Map to our package names | |
| if system == 'linux': | |
| if arch == 'x64': | |
| return 'gh-templates-linux-x64-glibc' | |
| elif arch == 'arm64': | |
| return 'gh-templates-linux-arm64-glibc' | |
| elif arch == 'x86': | |
| return 'gh-templates-linux-x86-musl' | |
| else: | |
| return f'gh-templates-linux-{arch}-glibc' | |
| elif system == 'darwin': | |
| return f'gh-templates-darwin-{arch}' | |
| elif system == 'windows': | |
| if arch == 'x64': | |
| return 'gh-templates-win32-x64-msvc' | |
| elif arch == 'x86': | |
| return 'gh-templates-win32-x86-msvc' | |
| else: | |
| return f'gh-templates-win32-{arch}-msvc' | |
| else: | |
| # Fallback to linux x64 | |
| return 'gh-templates-linux-x64-glibc' | |
| platform_package = get_platform_package() | |
| setup( | |
| name='gh-templates', | |
| version=version, | |
| description='GitHub Templates CLI tool - unified installer', | |
| long_description=''' | |
| # gh-templates | |
| GitHub Templates CLI tool for managing and using GitHub repository templates. | |
| This package automatically installs the correct binary for your platform. | |
| ## Usage | |
| ```bash | |
| pip install gh-templates | |
| gh-templates --help | |
| ``` | |
| ## Supported Platforms | |
| - Linux (x64, x86, ARM64) - glibc and musl variants | |
| - macOS (x64, ARM64) | |
| - Windows (x64, x86, ARM64) | |
| ''', | |
| long_description_content_type='text/markdown', | |
| packages=find_packages(), | |
| entry_points={ | |
| 'console_scripts': ['gh-templates=gh_templates:main'] | |
| }, | |
| install_requires=[ | |
| f'{platform_package}=={version}' | |
| ], | |
| license='Apache-2.0', | |
| author='Rafael John', | |
| url='https://github.com/RafaelJohn9/gh-templates', | |
| classifiers=[ | |
| 'Development Status :: 4 - Beta', | |
| 'Intended Audience :: Developers', | |
| 'License :: OSI Approved :: Apache Software License', | |
| 'Programming Language :: Python :: 3', | |
| 'Programming Language :: Python :: 3.7', | |
| 'Programming Language :: Python :: 3.8', | |
| 'Programming Language :: Python :: 3.9', | |
| 'Programming Language :: Python :: 3.10', | |
| 'Programming Language :: Python :: 3.11', | |
| 'Programming Language :: Python :: 3.12', | |
| 'Operating System :: OS Independent', | |
| 'Topic :: Utilities', | |
| ], | |
| python_requires='>=3.7', | |
| ) | |
| EOF | |
| # Create main module that delegates to platform-specific package | |
| cat > python-unified/gh_templates/__init__.py << 'EOF' | |
| """ | |
| GitHub Templates CLI tool - unified installer | |
| This package automatically delegates to the appropriate platform-specific binary. | |
| """ | |
| import sys | |
| import platform | |
| import importlib | |
| import subprocess | |
| import os | |
| def get_platform_package_name(): | |
| """Determine the platform-specific package name.""" | |
| system = platform.system().lower() | |
| machine = platform.machine().lower() | |
| # Normalize architecture names | |
| if machine in ['x86_64', 'amd64']: | |
| arch = 'x64' | |
| elif machine in ['aarch64', 'arm64']: | |
| arch = 'arm64' | |
| elif machine in ['i386', 'i686']: | |
| arch = 'x86' | |
| else: | |
| arch = machine | |
| # All platform-specific packages use the same module name | |
| return 'gh_templates_bin' | |
| def main(): | |
| """Main entry point that delegates to the platform-specific binary.""" | |
| try: | |
| # Import the platform-specific package | |
| package_name = get_platform_package_name() | |
| platform_module = importlib.import_module(package_name) | |
| # Call the main function from the platform-specific package | |
| if hasattr(platform_module, 'main'): | |
| platform_module.main() | |
| else: | |
| print(f"Error: No main function found in {package_name}") | |
| sys.exit(1) | |
| except ImportError as e: | |
| system = platform.system() | |
| machine = platform.machine() | |
| print(f"Error: Platform-specific package not found for {system}-{machine}") | |
| print(f"Import error: {e}") | |
| print() | |
| print("This usually means:") | |
| print("1. Your platform is not supported") | |
| print("2. The platform-specific package failed to install") | |
| print() | |
| print("Supported platforms:") | |
| print("- Linux x64/x86/ARM64 (glibc/musl)") | |
| print("- macOS x64/ARM64") | |
| print("- Windows x64/x86/ARM64") | |
| print() | |
| print("Please report this issue at:") | |
| print("https://github.com/RafaelJohn9/gh-templates/issues") | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f"Error running gh-templates: {e}") | |
| sys.exit(1) | |
| # Allow direct module execution | |
| if __name__ == '__main__': | |
| main() | |
| EOF | |
| # Create README for PyPI | |
| cat > python-unified/README.md << 'EOF' | |
| # gh-templates | |
| GitHub Templates CLI tool for managing and using GitHub repository templates. | |
| ## Installation | |
| ```bash | |
| pip install gh-templates | |
| ``` | |
| ## Usage | |
| ```bash | |
| gh-templates --help | |
| gh-templates --version | |
| ``` | |
| ## Platform Support | |
| This package automatically installs the correct binary for your platform: | |
| - **Linux**: x64, x86, ARM64 (glibc and musl variants) | |
| - **macOS**: x64 (Intel), ARM64 (Apple Silicon) | |
| - **Windows**: x64, x86, ARM64 | |
| ## How it Works | |
| This is a unified installer package that: | |
| 1. Detects your platform during installation | |
| 2. Installs the appropriate platform-specific package as a dependency | |
| 3. Provides a unified `gh-templates` command that delegates to the platform binary | |
| ## License | |
| Apache-2.0 | |
| EOF | |
| # Install dependencies and publish | |
| cd python-unified | |
| python -m pip install --upgrade pip setuptools wheel twine | |
| python setup.py sdist bdist_wheel | |
| python -m twine upload dist/* --skip-existing -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} | |
| publish-npm-unified: | |
| name: Publish unified NPM package | |
| runs-on: ubuntu-latest | |
| needs: publish-binaries | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Set release version | |
| run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Create unified package | |
| run: | | |
| mkdir -p gh-templates-unified/bin | |
| # Create package.json | |
| cat > gh-templates-unified/package.json << EOF | |
| { | |
| "name": "gh-templates", | |
| "version": "${{ env.RELEASE_VERSION }}", | |
| "description": "GitHub Templates CLI tool (platform-aware wrapper)", | |
| "bin": { | |
| "gh-templates": "./bin/gh-templates" | |
| }, | |
| "license": "Apache-2.0", | |
| "repository": { | |
| "type": "git", | |
| "url": "git+https://github.com/${{ github.repository }}.git" | |
| }, | |
| "optionalDependencies": { | |
| "gh-templates-linux-x64": "${{ env.RELEASE_VERSION }}", | |
| "gh-templates-linux-arm64": "${{ env.RELEASE_VERSION }}", | |
| "gh-templates-darwin-x64": "${{ env.RELEASE_VERSION }}", | |
| "gh-templates-darwin-arm64": "${{ env.RELEASE_VERSION }}", | |
| "gh-templates-windows-x64": "${{ env.RELEASE_VERSION }}", | |
| "gh-templates-windows-arm64": "${{ env.RELEASE_VERSION }}" | |
| }, | |
| "files": ["bin/"], | |
| "engines": { | |
| "node": ">=14" | |
| } | |
| } | |
| EOF | |
| # Create the smart wrapper | |
| cat > gh-templates-unified/bin/gh-templates << 'EOF' | |
| #!/usr/bin/env node | |
| const { execFileSync } = require('child_process'); | |
| const path = require('path'); | |
| const os = require('os'); | |
| const platform = os.platform(); | |
| const arch = os.arch(); | |
| let packageName; | |
| if (platform === 'win32') { | |
| if (arch === 'arm64') { | |
| packageName = 'gh-templates-windows-arm64'; | |
| } else { | |
| packageName = 'gh-templates-windows-x64'; | |
| } | |
| } else if (platform === 'darwin') { | |
| packageName = arch === 'arm64' ? 'gh-templates-darwin-arm64' : 'gh-templates-darwin-x64'; | |
| } else if (platform === 'linux') { | |
| packageName = arch === 'arm64' ? 'gh-templates-linux-arm64' : 'gh-templates-linux-x64'; | |
| } else { | |
| console.error(`Unsupported platform: ${platform}-${arch}`); | |
| process.exit(1); | |
| } | |
| try { | |
| const pkgPath = require.resolve(`${packageName}/package.json`); | |
| const binPath = path.join(path.dirname(pkgPath), 'bin', platform === 'win32' ? 'gh-templates.exe' : 'gh-templates'); | |
| execFileSync(binPath, process.argv.slice(2), { stdio: 'inherit' }); | |
| } catch (err) { | |
| console.error(`Platform-specific package not found: ${packageName}`); | |
| console.error(`Install it directly:`); | |
| console.error(` npm install -g ${packageName}`); | |
| console.error(` OR`); | |
| console.error(` npm install -g gh-templates-${platform}-${arch}`); | |
| process.exit(1); | |
| } | |
| EOF | |
| chmod +x gh-templates-unified/bin/gh-templates | |
| cd gh-templates-unified | |
| npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| publish-homebrew: | |
| name: Update Homebrew formula | |
| runs-on: macos-latest | |
| needs: publish-binaries | |
| steps: | |
| - name: Set release version | |
| run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Update Homebrew formula | |
| run: | | |
| VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//') | |
| # Get release assets | |
| LINUX_URL="https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gh-templates-linux-x64-glibc" | |
| DARWIN_ARM_URL="https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gh-templates-darwin-arm64" | |
| DARWIN_X64_URL="https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gh-templates-darwin-x64" | |
| # Calculate checksums | |
| wget -q $LINUX_URL -O linux-binary | |
| wget -q $DARWIN_ARM_URL -O darwin-arm-binary | |
| wget -q $DARWIN_X64_URL -O darwin-x64-binary | |
| LINUX_SHA=$(shasum -a 256 linux-binary | cut -d' ' -f1) | |
| DARWIN_ARM_SHA=$(shasum -a 256 darwin-arm-binary | cut -d' ' -f1) | |
| DARWIN_X64_SHA=$(shasum -a 256 darwin-x64-binary | cut -d' ' -f1) | |
| # Clone homebrew tap | |
| git clone https://github.com/rafaeljohn9/homebrew-tap.git | |
| cd homebrew-tap | |
| # Create/update formula | |
| cat > Formula/gh-templates.rb << EOF | |
| class GhTemplates < Formula | |
| desc "GitHub Templates CLI tool" | |
| homepage "https://github.com/${{ github.repository }}" | |
| version "$VERSION" | |
| on_macos do | |
| if Hardware::CPU.arm? | |
| url "$DARWIN_ARM_URL" | |
| sha256 "$DARWIN_ARM_SHA" | |
| else | |
| url "$DARWIN_X64_URL" | |
| sha256 "$DARWIN_X64_SHA" | |
| end | |
| end | |
| on_linux do | |
| url "$LINUX_URL" | |
| sha256 "$LINUX_SHA" | |
| end | |
| def install | |
| bin.install "gh-templates" | |
| end | |
| test do | |
| system "#{bin}/gh-templates", "--version" | |
| end | |
| end | |
| EOF | |
| # Commit and push | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/gh-templates.rb | |
| git commit -m "Update gh-templates to $VERSION" | |
| git push https://x-access-token:${{ secrets.HOMEBREW_GITHUB_TOKEN }}@github.com/rafaeljohn9/homebrew-tap.git |