Skip to content

Commit

Permalink
Commit for creating tag v0.0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
jfgiraud committed Feb 10, 2023
1 parent 481a1f2 commit acf3726
Show file tree
Hide file tree
Showing 18 changed files with 643 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
run: |
sudo make install-dependencies
make archive VERSION="${{ github.ref }}"
make archive
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down
96 changes: 64 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
DESTDIR ?= /usr/local
PACKAGE_NAME ?= quote-and-join
SCRIPTS = qaj uqaj
GENERATED_FILES = doc/generated/man/man1/qaj.1 doc/generated/txt/qaj.1.txt doc/generated/man/man1/uqaj.1 doc/generated/txt/uqaj.1.txt doc/generated/md/qaj.md doc/generated/md/uqaj.md
VERSION ?= $(shell cat doc/VERSION)
FILE_VERSION ?= $(shell cat doc/VERSION)

.ONESHELL:
SHELL=bash

## https://svn.lal.in2p3.fr/LCG/QWG/External/docbook-xsl-ns-1.74.0/tools/make/Makefile.DocBook

.PHONY: usage
usage:
@cat - <<EOF
Expand All @@ -9,69 +18,92 @@ usage:
* uninstall: remove scripts from /usr/local/bin
* test: run all tests
* archive: create a tgz (used in github pipeline for release)
* commit-release VERSION=v{X.Y.Z}: commit files and create a release
* update-doc VERSION=v{X.Y.Z}: update man pages and usages
* commit-release VERSION=X.Y.Z: commit files and create a release
* update-doc: update man pages and usages
* install-dependencies: install dependencies (you must call this target with sudo)
EOF

.PHONY: install-dependencies
install-dependencies:
apt install asciidoctor
apt install pandoc

/usr/bin/asciidoctor:
echo "You must install dependencies."
echo "sudo make install-dependencies"

doc/generated/man/man1/%.1: doc/%.adoc doc/VERSION
@echo "Create $@"
@asciidoctor -b manpage -a release-version="$(VERSION)" $< -o $@

doc/generated/md/%.md: doc/%.adoc doc/VERSION
@echo "Create $@"
@SCRIPT=$(shell basename "$@" | sed 's/\..*//')
@asciidoctor -b docbook doc/$$SCRIPT.adoc -o doc/generated/md/$$SCRIPT.xml
@pandoc -t gfm+footnotes -f docbook -t markdown_strict doc/generated/md/$$SCRIPT.xml -o doc/generated/md/$$SCRIPT.md
@rm -f doc/generated/md/$$SCRIPT.xml

doc/generated/txt/%.1.txt: doc/generated/man/man1/%.1 doc/VERSION
@echo "Create $@"
@man -l $< > $@
@SCRIPT=$(shell basename "$@" | sed 's/\..*//')
@echo "Rewrite usage in $$SCRIPT"
@awk -i inplace -v input="$@" 'BEGIN { p = 1 } /#BEGIN_DO_NOT_MODIFY:make update-doc/{ print; p = 0; while(getline line<input){print line} } /#END_DO_NOT_MODIFY:make update-doc/{ p = 1 } p' bin/$$SCRIPT

.PHONY: update-version
update-version:
[[ "$(VERSION)" == "$(FILE_VERSION)" ]] && echo "Change version number! (make update-version VERSION=X.Y.Z)" && exit 1
@echo "Modify version in doc/VERSION"
@echo "$(VERSION)" > doc/VERSION

.PHONY: update-doc
update-doc: doc/qaj.adoc doc/uqaj.adoc /usr/bin/asciidoctor
[[ -z $$VERSION ]] && echo "Version not set!" && exit 1
VERSION=$${VERSION#*v}
asciidoctor -b manpage doc/qaj.adoc -o doc/man/man1/qaj.1
awk -i inplace -v version=$$VERSION '/{release\\?-version}/{gsub(/{release\\?-version}/,version,$$0)} 1' doc/man/man1/qaj.1
man -l doc/man/man1/qaj.1 > doc/qaj.txt
[[ -s doc/qaj.txt ]] && awk -i inplace 'BEGIN { p = 1 } /#BEGIN_DO_NOT_MODIFY:make update-doc/{ print; p = 0; while(getline line<"doc/qaj.txt"){print line} } /#END_DO_NOT_MODIFY:make update-doc/{ p = 1 } p' bin/qaj
rm -f doc/qaj.txt
asciidoctor -b manpage doc/uqaj.adoc -o doc/man/man1/uqaj.1
awk -i inplace -v version=$$VERSION '/{release\\?-version}/{gsub(/{release\\?-version}/,version,$$0)} 1' doc/man/man1/uqaj.1
man -l doc/man/man1/uqaj.1 > doc/uqaj.txt
[[ -s doc/uqaj.txt ]] && awk -i inplace 'BEGIN { p = 1 } /#BEGIN_DO_NOT_MODIFY:make update-doc/{ print; p = 0; while(getline line<"doc/uqaj.txt"){print line} } /#END_DO_NOT_MODIFY:make update-doc/{ p = 1 } p' bin/uqaj
rm -f doc/uqaj.txt
update-doc: $(GENERATED_FILES)

.PHONY: commit-release
commit-release: clean update-doc
[[ -z $$VERSION ]] && echo "Version not set!" && exit 1
VERSION=$${VERSION#*v}
commit-release: update-version
@echo "Update documentation"
make update-doc
@echo "Commit release $$VERSION"
git add .
git commit -m "Commit for creating tag v$$VERSION"
git tag "v$$VERSION" -m "Tag v$$VERSION"
git push --tags


.PHONY: test
test:
bash tests/qaj_tests.sh
bash tests/uqaj_tests.sh

.PHONY: install
install: archive
tar zxvf quote-and-join.tar.gz -C /usr/local/

$(PACKAGE_NAME).tar.gz: $(PACKAGE_NAME).tar
@echo "Compress archive $@"
@gzip -f $<

$(PACKAGE_NAME).tar: update-doc
@echo "Create archive $@"
@tar cf $(PACKAGE_NAME).tar bin/*
@tar rf $(PACKAGE_NAME).tar LICENSE --transform 's,^,share/doc/$(PACKAGE_NAME)/,'
@tar rf $(PACKAGE_NAME).tar doc/generated/man/man1/*.1 --transform 's,^doc/generated/,,'

.PHONY: archive
archive:
tar cvf quote-and-join.tar bin/*qaj
tar rvf quote-and-join.tar LICENSE --transform 's,^,share/doc/quote-and-join/,'
tar rvf quote-and-join.tar doc/man/man1/*.1 --transform 's,^doc/,,'
gzip -f quote-and-join.tar
archive: $(PACKAGE_NAME).tar.gz

.PHONY: install
install: $(PACKAGE_NAME).tar.gz
@echo "Install software to $(DESTDIR)"
tar zxvf $(PACKAGE_NAME).tar.gz -C $(DESTDIR)

.PHONY: uninstall
uninstall:
cd /usr/local/
rm -f bin/{qaj,uqaj}
rm -f man/man1/{qaj,uqaj}.1
rm -f share/doc/quote-and-join/LICENSE
@echo "Uninstall software from $(DESTDIR)"
@for script in $(SCRIPTS); do
@ rm -f $(DESTDIR)/bin/$$script $(DESTDIR)/man/man1/$$script.1
@done
@rm -rf $(DESTDIR)/share/doc/$(PACKAGE_NAME)/

.PHONY: clean
clean:
rm -f *.tar *.gz *~
@echo "Clean files"
@rm -f $(PACKAGE_NAME).tar.gz


5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ quote and join words or lines in files

## examples

```
```bash
$ echo lorem ipsum dolores est | qaj -w -q -j,
```

```
'lorem','ipsum','dolores','est'
$ echo lorem ipsum dolores est | qaj -w -qq -j', '
Expand Down
4 changes: 2 additions & 2 deletions bin/qaj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NAME
qaj - quote and join words or lines in files
SYNOPSIS
qaj [OPTION]... [FILE]...
qaj [OPTION] [FILE]
DESCRIPTION
qaj is a small utility to:
Expand Down Expand Up @@ -142,7 +142,7 @@ COPYRIGHT
Copyright © 2020 Jean-François Giraud. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO
WARRANTY, to the extent permitted by law.
quote-and-join 0.0.21 2023-02-09 QAJ(1)
quote-and-join 0.0.35 2023-02-10 QAJ(1)
#END_DO_NOT_MODIFY:make update-doc
EOF
) | tail -n +4 | head -n -9
Expand Down
2 changes: 1 addition & 1 deletion bin/uqaj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ COPYRIGHT
Copyright © 2020 Jean-François Giraud. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO
WARRANTY, to the extent permitted by law.
quote-and-join 0.0.21 2023-02-09 UQAJ(1)
quote-and-join 0.0.35 2023-02-10 UQAJ(1)
#END_DO_NOT_MODIFY:make update-doc
EOF
) | tail -n +4 | head -n -9
Expand Down
1 change: 1 addition & 0 deletions doc/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.35
4 changes: 4 additions & 0 deletions doc/author.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
== AUTHOR

Written by Jean-François Giraud.

4 changes: 4 additions & 0 deletions doc/copyright.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
== COPYRIGHT

Copyright (C) 2020 Jean-François Giraud. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
10 changes: 5 additions & 5 deletions doc/man/man1/qaj.1 → doc/generated/man/man1/qaj.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: qaj
.\" Author: [see the "AUTHORS" section]
.\" Generator: Asciidoctor 1.5.5
.\" Date: 2023-02-09
.\" Date: 2023-02-10
.\" Manual: User commands
.\" Source: quote-and-join 0.0.21
.\" Source: quote-and-join 0.0.35
.\" Language: English
.\"
.TH "QAJ" "1" "2023-02-09" "quote\-and\-join 0.0.21" "User commands"
.TH "QAJ" "1" "2023-02-10" "quote\-and\-join 0.0.35" "User commands"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
Expand All @@ -22,7 +22,7 @@
qaj \- quote and join words or lines in files
.SH "SYNOPSIS"
.sp
\fBqaj\fP [\fIOPTION\fP]... [\fIFILE\fP]...
\fBqaj\fP [\fIOPTION\fP] [\fIFILE\fP]
.SH "DESCRIPTION"
.sp
qaj is a small utility to:
Expand Down Expand Up @@ -301,4 +301,4 @@ Written by Jean\-François Giraud.
.sp
Copyright \(co 2020 Jean\-François Giraud. License GPLv3+: GNU GPL version 3 or later \c
.URL "http://gnu.org/licenses/gpl.html" "" "."
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
8 changes: 4 additions & 4 deletions doc/man/man1/uqaj.1 → doc/generated/man/man1/uqaj.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: uqaj
.\" Author: [see the "AUTHORS" section]
.\" Generator: Asciidoctor 1.5.5
.\" Date: 2023-02-09
.\" Date: 2023-02-10
.\" Manual: User commands
.\" Source: quote-and-join 0.0.21
.\" Source: quote-and-join 0.0.35
.\" Language: English
.\"
.TH "UQAJ" "1" "2023-02-09" "quote\-and\-join 0.0.21" "User commands"
.TH "UQAJ" "1" "2023-02-10" "quote\-and\-join 0.0.35" "User commands"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
Expand Down Expand Up @@ -135,4 +135,4 @@ Written by Jean\-François Giraud.
.sp
Copyright \(co 2020 Jean\-François Giraud. License GPLv3+: GNU GPL version 3 or later \c
.URL "http://gnu.org/licenses/gpl.html" "" "."
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Loading

0 comments on commit acf3726

Please sign in to comment.