diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml deleted file mode 100644 index b42baf7..0000000 --- a/.github/workflows/c-cpp.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: C/C++ CI - -on: - push: - branches: [ "master", "**" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: make - run: make diff --git a/.github/workflows/macos-matrix.yml b/.github/workflows/macos-matrix.yml new file mode 100644 index 0000000..3e3e5a2 --- /dev/null +++ b/.github/workflows/macos-matrix.yml @@ -0,0 +1,50 @@ +name: macos-matrix + +# Controls when the action will run. +on: + pull_request: + branches: + - '*' + - '*/*' + - '**' + - 'master' + - 'main' + push: + branches: + - '*' + - '*/*' + - '**' + - 'master' + - 'main' + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + macos-build_and_test: + strategy: + matrix: + os: [macos-latest, macos-11, macos-12] + runs-on: ${{ matrix.os }} + steps: + - uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - name: printenv + run: | + brew install libtool autoconf automake + printenv + - name: make + run: | + make + - name: sudo make install + run: | + sudo make install + - name: man nostril + run: | + man nostril + - name: sudo -su runner nostril + run: | + #pipe handles non-zero return from nostril default help + sudo -su runner nostril | echo "${PIPESTATUS[0]}" diff --git a/.github/workflows/macos-pre-release.yml b/.github/workflows/macos-pre-release.yml new file mode 100644 index 0000000..0f6b373 --- /dev/null +++ b/.github/workflows/macos-pre-release.yml @@ -0,0 +1,47 @@ +name: macos-pre-release + +# Controls when the action will run. +on: + push: + branches: + - 'master' + - '**pre-release**' + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + pre-release: + strategy: + matrix: + os: [macos-11, macos-12, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - name: "printenv" + run: | + brew install libtool autoconf automake + printenv + - name: "Build pre-release" + run: | + make + mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + ls -a + - name: Save state + run: echo "{name}={value}" >> $GITHUB_STATE + - name: Set output + run: echo "{name}={value}" >> $GITHUB_OUTPUT + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{ matrix.os }} + prerelease: true + title: "Development Build" + files: | + nostril-* diff --git a/.github/workflows/macos-release.yml b/.github/workflows/macos-release.yml new file mode 100644 index 0000000..3fbaf9b --- /dev/null +++ b/.github/workflows/macos-release.yml @@ -0,0 +1,47 @@ +name: macos-release + +# Controls when the action will run. +on: + push: + tags: + - "v*" + - "v*.*.*-rc**" + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + release: + strategy: + matrix: + os: [macos-11, macos-12, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - name: "printenv" + run: | + brew install libtool autoconf automake + printenv + - name: "Build release" + run: | + make + mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + ls -a + - name: Save state + run: echo "{name}={value}" >> $GITHUB_STATE + - name: Set output + run: echo "{name}={value}" >> $GITHUB_OUTPUT + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{ matrix.os }} + prerelease: false + title: "Release Build" + files: | + nostril-* diff --git a/.github/workflows/ubuntu-matrix.yml b/.github/workflows/ubuntu-matrix.yml new file mode 100644 index 0000000..f269c86 --- /dev/null +++ b/.github/workflows/ubuntu-matrix.yml @@ -0,0 +1,59 @@ +name: ubuntu-matrix + +# Controls when the action will run. +on: + pull_request: + branches: + - '*' + - '*/*' + - '**' + - 'master' + - 'main' + push: + branches: + - '*' + - '*/*' + - '**' + - 'master' + - 'main' + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + ubuntu-build_and_test: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: styfle/cancel-workflow-action@0.11.0 + if: ${{ !env.ACT }} + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v3 + with: + fetch-depth: '0' + submodules: 'recursive' + set-safe-directory: 'true' + - name: printenv && sudo apt update && sudo apt install scdoc -y + run: | + printenv && sudo apt update && sudo apt install scdoc -y + - name: rm -rf deps + run: | + rm -rf deps + - name: make + run: | + mkdir -p /usr/local/share/man/man1/nostril.1 + make + - name: sudo make install + run: | + sudo make install + - name: man nostril + run: | + man nostril + - name: sudo ./nostril + run: | + #pipe handles non-zero return from nostril default help + file nostril + sudo ./nostril >/dev/null | echo "${PIPESTATUS[0]}" diff --git a/.github/workflows/ubuntu-pre-release.yml b/.github/workflows/ubuntu-pre-release.yml new file mode 100644 index 0000000..8096f0b --- /dev/null +++ b/.github/workflows/ubuntu-pre-release.yml @@ -0,0 +1,53 @@ +name: ubuntu-pre-release + +# Controls when the action will run. +on: + push: + branches: + - 'master' + - '**pre-release**' + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + pre-release: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: styfle/cancel-workflow-action@0.11.0 + if: ${{ !env.ACT }} + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v3 + with: + fetch-depth: '0' + submodules: 'recursive' + set-safe-directory: 'true' + - name: printenv && sudo apt update && sudo apt install scdoc -y + run: | + printenv && sudo apt update && sudo apt install scdoc -y + - name: "Build pre-release" + run: | + mkdir -p /usr/local/share/man/man1/nostril.1 + make nostril + mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + ls -a + - name: Save state + run: echo "{name}={value}" >> $GITHUB_STATE + - name: Set output + run: echo "{name}={value}" >> $GITHUB_OUTPUT + - uses: "marvinpinto/action-automatic-releases@latest" + if: ${{ !env.ACT }} + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{ matrix.os }} + prerelease: true + title: "Development Build" + files: | + nostril-* diff --git a/.github/workflows/ubuntu-release.yml b/.github/workflows/ubuntu-release.yml new file mode 100644 index 0000000..f59e20a --- /dev/null +++ b/.github/workflows/ubuntu-release.yml @@ -0,0 +1,53 @@ +name: ubuntu-release + +# Controls when the action will run. +on: + push: + tags: + - "v*" + - "v*.*.*-rc**" + + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + release: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: styfle/cancel-workflow-action@0.11.0 + if: ${{ !env.ACT }} + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v3 + with: + fetch-depth: '0' + submodules: 'recursive' + set-safe-directory: 'true' + - name: printenv && sudo apt update && sudo apt install scdoc -y + run: | + printenv && sudo apt update && sudo apt install scdoc -y + - name: "Build release" + run: | + mkdir -p /usr/local/share/man/man1/nostril.1 + make nostril + mv nostril nostril-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-$RUNNER_OS-$RUNNER_ARCH > nostril-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + mv nostril-query nostril-query-$RUNNER_OS-$RUNNER_ARCH + shasum -a 256 nostril-query-$RUNNER_OS-$RUNNER_ARCH > nostril-query-$RUNNER_OS-$RUNNER_ARCH.sha256.txt + ls -a + - name: Save state + run: echo "{name}={value}" >> $GITHUB_STATE + - name: Set output + run: echo "{name}={value}" >> $GITHUB_OUTPUT + - uses: "marvinpinto/action-automatic-releases@latest" + if: ${{ !env.ACT }} + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: ${{ matrix.os }} + prerelease: false + title: "Release Build" + files: | + nostril-* diff --git a/.gitignore b/.gitignore index 47f90da..dcbd75b 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ scripts/nostr-req scripts/subnote /dist /version + +.DS_Store +deps/.DS_Store diff --git a/.gitmodules b/.gitmodules index 967defe..0f87e1a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "deps/secp256k1"] path = deps/secp256k1 url = https://github.com/bitcoin-core/secp256k1 + ignore = dirty + branch = master + depth = shallow diff --git a/CMakeLists.txt b/CMakeLists.txt index 05450b4..a566d58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,11 @@ else() cmake_minimum_required(VERSION 3.15) endif() set(CMAKE_BUILD_TYPE Debug) +option(BUILD_RELEASE "BUILD_RELEASE" ON) +if(BUILD_RELEASE) + set(CMAKE_BUILD_TYPE Release) +endif() + project (nostril C) include_directories(${CMAKE_SOURCE_DIR}/ext/secp256k1/include) @@ -71,8 +76,18 @@ target_link_libraries (nostril ${lib_dep}) add_custom_command( TARGET configurator POST_BUILD - COMMAND configurator > config.h + COMMAND configurator > config.h COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/config.h" ${CMAKE_SOURCE_DIR} COMMENT "generating config.h" ) +#////////////////////////// +# Install +#////////////////////////// + +install(TARGETS nostril + CONFIGURATIONS Debug + RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin) +install(TARGETS nostril + CONFIGURATIONS Release + RUNTIME DESTINATION /usr/local/bin) diff --git a/Makefile b/Makefile index 3000e1e..208af89 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,19 @@ ARS = libsecp256k1.a SUBMODULES = deps/secp256k1 -all: nostril docs +default: + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) +help:## print verbose help + @echo '' + @echo 'Usage: make [TARGET] [EXTRA_ARGUMENTS]' + @echo '' + @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ': ' | sed -e 's/^/ /' ## verbose help ideas + @sed -n 's/^## //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' + @echo "" + @echo "Useful Commands:" + @echo "" + +all: nostril docs## nostril docs docs: doc/nostril.1 @@ -34,6 +46,8 @@ deps/secp256k1/include/secp256k1.h: deps/secp256k1/.git deps/secp256k1/configure: deps/secp256k1/.git cd deps/secp256k1; \ + automake --add-missing; \ + autoreconf; \ ./autogen.sh deps/secp256k1/config.log: deps/secp256k1/configure @@ -55,9 +69,10 @@ nostril: $(HEADERS) $(OBJS) $(ARS) $(CC) $(CFLAGS) $(OBJS) $(ARS) -o $@ install: all - install -Dm644 doc/nostril.1 $(PREFIX)/share/man/man1/nostril.1 - install -Dm755 nostril $(PREFIX)/bin/nostril - install -Dm755 nostril-query $(PREFIX)/bin/nostril-query + mkdir -p $(PREFIX)/bin + install -m644 doc/nostril.1 $(PREFIX)/share/man/man1/nostril.1 + install -m755 nostril $(PREFIX)/bin/nostril + install -m755 nostril-query $(PREFIX)/bin/nostril-query config.h: configurator ./configurator > $@ @@ -72,4 +87,4 @@ clean: tags: fake ctags *.c *.h -.PHONY: fake +.PHONY: fake nostril diff --git a/nostril.c b/nostril.c index 5bd279e..56e5f29 100644 --- a/nostril.c +++ b/nostril.c @@ -97,7 +97,7 @@ void usage() printf(" -e shorthand for --tag e \n"); printf(" -p shorthand for --tag p \n"); printf(" -t shorthand for --tag t \n"); - exit(1); + exit(0); }