From 024b32fd696378ac14b9022f2a187ce75417104d Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Tue, 7 Jan 2025 06:29:07 +0530 Subject: [PATCH] feat: prepare for v1 release --- .github/workflows/build.yml | 46 ++++++++++++++------------- .github/workflows/release.yml | 47 ---------------------------- .goreleaser.yml | 15 +++++++++ install.sh | 58 +++++++++++++++++++++++++++++++++++ readme.md | 10 ++++++ 5 files changed, 108 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml create mode 100644 install.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24b0fa5..05fbe8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,32 +1,36 @@ +name: build + on: push: - branches: - - "**" + tags: + - "*" -name: Build -env: - GO_VERSION: 1.23 +permissions: + contents: write jobs: - build: - name: Run checks and build + goreleaser: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 + - name: Checkout + uses: actions/checkout@v4 with: - go-version: ${{env.GO_VERSION}} - - format: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v5 with: - go-version: ${{env.GO_VERSION}} - - - run: go fmt ./... \ No newline at end of file + go-version: stable + # More assembly might be required: Docker logins, GPG, etc. + # It all depends on your needs. + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 2814087..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Release -on: - push: - tags: [ v* ] - -env: - GO_VERSION: 1.23 - REPO: ${{ github.repository }} - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - GOOS: [linux, darwin, windows] - GOARCH: [amd64, arm64] - include: - - GOOS: windows - ext: .exe - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Repo Name - id: repo-name - run: echo name=$(basename ${{ github.repository }}) >> $GITHUB_OUTPUT - - - name: Test - run: go test -v ./... - - - name: Build - run: make package PROGRAM=${{ env.GOOS }}-${{ env.GOARCH }}/${{ steps.repo-name.outputs.name }}${{ matrix.ext }} PACKAGE=dist/${{ steps.repo-name.outputs.name }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}.zip - env: - GOOS: ${{ matrix.GOOS }} - GOARCH: ${{ matrix.GOARCH }} - - - name: 'Upload Artifact' - uses: actions/upload-artifact@v4 - with: - name: artifacts-${{ matrix.GOOS }}-${{ matrix.GOARCH }} - path: dist - retention-days: 1 - if-no-files-found: error \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..6573984 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,15 @@ +project_name: "ginister" + +before: + hooks: + - go mod tidy + - go mod download + +builds: + - main: ./main.go + binary: ginister + goos: + - linux + - darwin + goarm: + - "7" \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..8b70df2 --- /dev/null +++ b/install.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env sh + +set -e + +# Determine OS and architecture +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +case $ARCH in + x86_64) + ARCH="amd64" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + i386|i686) + ARCH="386" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; +esac + +# Check for version argument +# Otherwise, set latest release version +if [ -z "$VERSION" ]; then + VERSION=$(curl -s "https://api.github.com/repos/fOSS-Community/ginister/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([0-9.]+)".*/\1/') +fi + +# Construct download URL +DOWNLOAD_URL="https://github.com/fOSS-Community/ginister/releases/download/v${VERSION}/ginister_${VERSION}_${OS}_${ARCH}.tar.gz" + +# Create temporary directory +TMP_DIR=$(mktemp -d) +trap 'rm -rf "$TMP_DIR"' EXIT + +# Download and extract +echo "Downloading ginister ${VERSION} for ${OS} ${ARCH}..." +curl -L -s "$DOWNLOAD_URL" | tar -xz -C "$TMP_DIR" + +# Check if directory is writable by the current user +# If not, use sudo to install +INSTALL_DIR=${INSTALL_DIR:-/usr/local/bin} +if [ ! -w "$INSTALL_DIR" ]; then + echo "Installing ginister to $INSTALL_DIR..." + sudo mkdir -p "$INSTALL_DIR" + sudo mv "$TMP_DIR/ginister" "$INSTALL_DIR/" +else + echo "Installing ginister to $INSTALL_DIR..." + mkdir -p "$INSTALL_DIR" + mv "$TMP_DIR/ginister" "$INSTALL_DIR/" +fi + +echo "ginister ${VERSION} has been installed successfully!" +echo "Be sure that $INSTALL_DIR is in your PATH:" +printf "\n\texport PATH=\$PATH:%s\n\n" "$INSTALL_DIR" +echo "You can now use the 'ginister' command." \ No newline at end of file diff --git a/readme.md b/readme.md index fc38e3c..d0fca01 100644 --- a/readme.md +++ b/readme.md @@ -16,6 +16,16 @@ Ginister is a Go CLI tool that helps you quickly scaffold a fully functioning ba ## Installation +### How to install + +```sh +curl -L https://fosscu.org/ginister/install.sh | sh +``` + +This will install ginister on your computer. + +### Install Manually + Clone the repository and build the CLI tool: ```bash