From ae0a3ffa12712b2435214df43fb8d5332ecd1287 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 30 Jan 2021 23:19:05 +0100 Subject: [PATCH 1/8] Use jq to construct a valid json API message --- gpgit.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gpgit.sh b/gpgit.sh index bc252ea..9be2fb0 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -778,8 +778,13 @@ else warning "Publishing release on default Github branch '${BRANCH}'." fi - API_JSON="$(printf '{"tag_name": "%s","target_commitish": "%s","name": "%s","body": "%s","draft": false,"prerelease": %s}' \ - "${TAG}" "${BRANCH}" "${TAG}" "${MESSAGE//$'\n'/'\n'}" "${PRERELEASE}")" + API_JSON="$(jq -n -C \ + --arg tag_name "${TAG}" \ + --arg target_commitish "${BRANCH}" \ + --arg name "${TAG}" \ + --arg body "${MESSAGE}" \ + --arg prerelease "${PRERELEASE}" \ + '{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: $prerelease }')" if ! GITHUB_RELEASE="$(curl --proto-redir =https -s --data "${API_JSON}" \ "https://github.com/gitapi/repos/${GITHUB_REPO_NAME}/releases" \ -H "Accept: application/vnd.github.v3+json" \ From c01c0c1858cf2a766076d9d3c09c7d8b515b859b Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 30 Jan 2021 23:32:04 +0100 Subject: [PATCH 2/8] Correct jq json output --- gpgit.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gpgit.sh b/gpgit.sh index 9be2fb0..ca78f41 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -783,8 +783,9 @@ else --arg target_commitish "${BRANCH}" \ --arg name "${TAG}" \ --arg body "${MESSAGE}" \ - --arg prerelease "${PRERELEASE}" \ - '{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: $prerelease }')" + --argjson prerelease "${PRERELEASE}" \ + '{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: $prerelease}')" + if ! GITHUB_RELEASE="$(curl --proto-redir =https -s --data "${API_JSON}" \ "https://github.com/gitapi/repos/${GITHUB_REPO_NAME}/releases" \ -H "Accept: application/vnd.github.v3+json" \ From 38cf837e283511ed034d327c915aedf30bf7fc14 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 30 Jan 2021 23:32:18 +0100 Subject: [PATCH 3/8] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb6362..f9ff146 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ This changlog uses the [ISO 8601 date format](https://www.iso.org/iso-8601-date- ## [Unreleased] +### Fixed + +* Fixed Github API json escaping issue + ## [1.4.0] - 2021-01-29 ### Added From 53f3bc4f635d8d7390684b382badff48b9c2e0b0 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 30 Jan 2021 23:36:11 +0100 Subject: [PATCH 4/8] Fix jq parameters --- gpgit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpgit.sh b/gpgit.sh index ca78f41..ebbc473 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -778,7 +778,7 @@ else warning "Publishing release on default Github branch '${BRANCH}'." fi - API_JSON="$(jq -n -C \ + API_JSON="$(jq -n -c -M \ --arg tag_name "${TAG}" \ --arg target_commitish "${BRANCH}" \ --arg name "${TAG}" \ From f16790cce1befca678bc0746e0b13e82b079de1d Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 30 Jan 2021 23:36:47 +0100 Subject: [PATCH 5/8] Remove empty line --- gpgit.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/gpgit.sh b/gpgit.sh index ebbc473..724f957 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -785,7 +785,6 @@ else --arg body "${MESSAGE}" \ --argjson prerelease "${PRERELEASE}" \ '{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: $prerelease}')" - if ! GITHUB_RELEASE="$(curl --proto-redir =https -s --data "${API_JSON}" \ "https://github.com/gitapi/repos/${GITHUB_REPO_NAME}/releases" \ -H "Accept: application/vnd.github.v3+json" \ From 1f27a3047399f28f171b233da11175b14dbb925a Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 31 Jan 2021 09:51:09 +0100 Subject: [PATCH 6/8] Added depcrecated warning about --no-github parameter --- gpgit.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gpgit.sh b/gpgit.sh index 724f957..d71bb3b 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -255,6 +255,7 @@ while true ; do ;; # DEPRECATED: use '--github false' or git config 'gpgit.github false' -n|--no-github) + INTERACTIVE=false warning "Parameter '--no-github' is deprecated. Please use '--github false' instead." GITHUB="false" ;; -f|--force) From c0f75085f7604c95e8e82f2a585bc207c2ff837f Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 31 Jan 2021 10:08:41 +0100 Subject: [PATCH 7/8] Update license date and add license to script --- LICENSE | 2 +- gpgit.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index e8f1fa9..4459e47 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016 NicoHood +Copyright (c) 2016-2021 NicoHood Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/gpgit.sh b/gpgit.sh index d71bb3b..c516760 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -1,4 +1,25 @@ #!/usr/bin/env bash + +# Copyright (c) 2016-2021 NicoHood +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +# OR OTHER DEALINGS IN THE SOFTWARE. + VERSION="1.4.0" # Avoid any encoding problems From f84d7563ed3e78eb596ff37357ddec9f4c6cf0e8 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 31 Jan 2021 10:26:31 +0100 Subject: [PATCH 8/8] Update changelog and readme for 1.4.1 release --- CHANGELOG.md | 10 +++++++++- Readme.md | 5 +++-- gpgit.sh | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9ff146..2cb84d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,16 @@ This changlog uses the [ISO 8601 date format](https://www.iso.org/iso-8601-date- ## [Unreleased] +## [1.4.1] - 2021-01-31 + +### Changed + +* Update license date and add license to script + ### Fixed * Fixed Github API json escaping issue +* Added depcrecated warning about `--no-github` parameter ## [1.4.0] - 2021-01-29 @@ -174,7 +181,8 @@ This changlog uses the [ISO 8601 date format](https://www.iso.org/iso-8601-date- ### Added - Initial release of the software -[Unreleased]: https://github.com/NicoHood/gpgit/compare/1.4.0...HEAD +[Unreleased]: https://github.com/NicoHood/gpgit/compare/1.4.1...HEAD +[1.4.1]: https://github.com/NicoHood/gpgit/compare/1.4.0...1.4.1 [1.4.0]: https://github.com/NicoHood/gpgit/compare/1.3.4...1.4.0 [1.3.4]: https://github.com/NicoHood/gpgit/compare/1.3.3...1.3.4 [1.3.3]: https://github.com/NicoHood/gpgit/compare/1.3.2...1.3.3 diff --git a/Readme.md b/Readme.md index 0cfde07..63a5321 100644 --- a/Readme.md +++ b/Readme.md @@ -52,13 +52,14 @@ The security status of GNU/Linux projects will be tracked in the [Linux Security * [Arch Linux](https://archlinux.org/packages/community/any/gpgit/) `sudo pacman -S gpgit` ### Manual Installation + ```bash # Install dependencies and optional dependencies sudo apt-get install bash gnupg2 git tar xz-utils coreutils gawk grep sed sudo apt-get install gzip bzip lzip file jq curl # Download and verify source -VERSION=1.4.0 +VERSION=1.4.1 wget "https://github.com/NicoHood/gpgit/releases/download/${VERSION}/gpgit-${VERSION}.tar.xz" wget "https://github.com/NicoHood/gpgit/releases/download/${VERSION}/gpgit-${VERSION}.tar.xz.asc" gpg2 --keyserver hkps://keyserver.ubuntu.com --recv-keys 97312D5EB9D7AE7D0BD4307351DAE9B7C1AE9161 @@ -83,7 +84,7 @@ If you add and commit a `CHANGELOG.md` file to your Git with the [Keep a Changel $ gpgit --help Usage: gpgit [options] [ | ] -GPGit 1.4.0 https://github.com/NicoHood/gpgit +GPGit 1.4.1 https://github.com/NicoHood/gpgit A shell script that automates the process of signing Git sources via GPG. Mandatory arguments: diff --git a/gpgit.sh b/gpgit.sh index c516760..e126ffb 100755 --- a/gpgit.sh +++ b/gpgit.sh @@ -20,7 +20,7 @@ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE # OR OTHER DEALINGS IN THE SOFTWARE. -VERSION="1.4.0" +VERSION="1.4.1" # Avoid any encoding problems export LANG=C