From 585439d4737b8fc664cb793dc2d36f5b6a5ad1a3 Mon Sep 17 00:00:00 2001 From: Martin Scheidt Date: Sun, 13 Feb 2022 19:47:16 +0100 Subject: [PATCH] modified release script for automated releases --- .github/tex/profile.basic.txt | 13 ++ .github/tex/profile.full.txt | 13 ++ .github/tex/profile.medium.txt | 13 ++ .github/tex/profile.minimal.txt | 13 ++ .github/tex/profile.small.txt | 13 ++ .github/tex/texlive.profile.txt | 9 -- .github/workflows/debug.yml | 8 +- .github/workflows/release.yaml | 89 +++++++++++ .github/workflows/testing.yml | 4 +- CONTRIBUTING.md | 3 +- create-release.sh | 139 ++++++++++++++++++ create_ctan-package.sh | 42 ------ ...ymbology_table.pdf => symbology-table.pdf} | Bin ...ymbology_table.tex => symbology-table.tex} | 0 src/tikz-trackschematic.sty | 4 +- 15 files changed, 302 insertions(+), 61 deletions(-) create mode 100644 .github/tex/profile.basic.txt create mode 100644 .github/tex/profile.full.txt create mode 100644 .github/tex/profile.medium.txt create mode 100644 .github/tex/profile.minimal.txt create mode 100644 .github/tex/profile.small.txt delete mode 100644 .github/tex/texlive.profile.txt create mode 100644 .github/workflows/release.yaml create mode 100755 create-release.sh delete mode 100755 create_ctan-package.sh rename doc/{symbology_table.pdf => symbology-table.pdf} (100%) rename doc/{symbology_table.tex => symbology-table.tex} (100%) diff --git a/.github/tex/profile.basic.txt b/.github/tex/profile.basic.txt new file mode 100644 index 0000000..114533e --- /dev/null +++ b/.github/tex/profile.basic.txt @@ -0,0 +1,13 @@ +# .github/tex/basic.profile.txt +# used for paolobrasolin/setup-texlive-action@v1 +# Install the scheme: +# +# basic scheme ( and latex) +# +selected_scheme scheme-basic +# Omit documentation files: +tlpdbopt_install_docfiles 0 +# Omit source files: +tlpdbopt_install_srcfiles 0 +# Avoid doing backups: +tlpdbopt_autobackup 0 \ No newline at end of file diff --git a/.github/tex/profile.full.txt b/.github/tex/profile.full.txt new file mode 100644 index 0000000..fba2715 --- /dev/null +++ b/.github/tex/profile.full.txt @@ -0,0 +1,13 @@ +# .github/tex/full.profile.txt +# used for paolobrasolin/setup-texlive-action@v1 +# Install the scheme: +# +# full scheme (everything) +# +selected_scheme scheme-full +# Omit documentation files: +tlpdbopt_install_docfiles 0 +# Omit source files: +tlpdbopt_install_srcfiles 0 +# Avoid doing backups: +tlpdbopt_autobackup 0 \ No newline at end of file diff --git a/.github/tex/profile.medium.txt b/.github/tex/profile.medium.txt new file mode 100644 index 0000000..f4c8a5e --- /dev/null +++ b/.github/tex/profile.medium.txt @@ -0,0 +1,13 @@ +# .github/tex/medium.profile.txt +# used for paolobrasolin/setup-texlive-action@v1 +# Install the scheme: +# +# medium scheme ( + more packages and languages) +# +selected_scheme scheme-medium +# Omit documentation files: +tlpdbopt_install_docfiles 0 +# Omit source files: +tlpdbopt_install_srcfiles 0 +# Avoid doing backups: +tlpdbopt_autobackup 0 \ No newline at end of file diff --git a/.github/tex/profile.minimal.txt b/.github/tex/profile.minimal.txt new file mode 100644 index 0000000..9f3f681 --- /dev/null +++ b/.github/tex/profile.minimal.txt @@ -0,0 +1,13 @@ +# .github/tex/minimal.profile.txt +# used for paolobrasolin/setup-texlive-action@v1 +# Install the scheme: +# +# minimal scheme (plain only) +# +selected_scheme scheme-minimal +# Omit documentation files: +tlpdbopt_install_docfiles 0 +# Omit source files: +tlpdbopt_install_srcfiles 0 +# Avoid doing backups: +tlpdbopt_autobackup 0 \ No newline at end of file diff --git a/.github/tex/profile.small.txt b/.github/tex/profile.small.txt new file mode 100644 index 0000000..5aa9787 --- /dev/null +++ b/.github/tex/profile.small.txt @@ -0,0 +1,13 @@ +# .github/tex/small.profile.txt +# used for paolobrasolin/setup-texlive-action@v1 +# Install the scheme: +# +# small scheme ( + xetex, metapost, and a few languages) +# +selected_scheme scheme-small +# Omit documentation files: +tlpdbopt_install_docfiles 0 +# Omit source files: +tlpdbopt_install_srcfiles 0 +# Avoid doing backups: +tlpdbopt_autobackup 0 \ No newline at end of file diff --git a/.github/tex/texlive.profile.txt b/.github/tex/texlive.profile.txt deleted file mode 100644 index d5967ad..0000000 --- a/.github/tex/texlive.profile.txt +++ /dev/null @@ -1,9 +0,0 @@ -# .github/texlive.profile -# Install the scheme minimal: -selected_scheme scheme-minimal -# Omit documentation files: -tlpdbopt_install_docfiles 0 -# Omit source files: -tlpdbopt_install_srcfiles 0 -# Avoid doing backups: -tlpdbopt_autobackup 0 \ No newline at end of file diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 61d783d..34e27d4 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -40,19 +40,19 @@ jobs: # # old TeX Live version: 2019 # uses: DanySK/setup-texlive-action@master # with: - # requirements-file: .github/tex/packages.test.txt + # requirements-file: .github/tex/test.packages.txt # ## # - name: "setup TeX Live (via teatimeguest)" # # tlmgr needs updates and fails # uses: teatimeguest/setup-texlive-action@v1 # with: - # package-file: .github/tex/packages.test.txt + # package-file: .github/tex/test.packages.txt # ## - name: "setup TeX Live (via paolobrasolin)" uses: paolobrasolin/setup-texlive-action@v1 with: - profile-path: ${{ github.workspace }}/.github/tex/texlive.profile.txt - packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt + profile-path: ${{ github.workspace }}/.github/tex/minimal.profile.txt + packages-path: ${{ github.workspace }}/.github/tex/test.packages.txt - name: "install tikz-trackschematic" run: chmod +x dev-install.sh && ./dev-install.sh -b diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..c043287 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,89 @@ +name: "release" + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + tags: + - "v*" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + test: + name: "test" + # The type of runner that the job will run on + runs-on: ubuntu-latest + + steps: + - name: "checkout" + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + uses: actions/checkout@v2 + + - name: "change ImageMagick policy to allow pdf->png conversion" + run: sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml + + - name: "install ghostscript" + run: sudo apt-get install -y ghostscript + + - name: "setup TeX Live (via paolobrasolin)" + uses: paolobrasolin/setup-texlive-action@v1 + with: + profile-path: ${{ github.workspace }}/.github/tex/minimal.profile.txt + packages-path: ${{ github.workspace }}/.github/tex/test.packages.txt + + - name: "install tikz-trackschematic" + run: chmod +x dev-install.sh && ./dev-install.sh -b + + - name: "test tikz-trackschematic" + run: cd test && chmod +x testing.sh && ./testing.sh + + release: + needs: test + name: "make release" + # The type of runner that the job will run on + runs-on: ubuntu-latest + + steps: + - name: "checkout" + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + uses: actions/checkout@v2 + + - name: "create tikz-trackschematic package" + env: + TAG_NAME: ${{ contains(github.event.head_commit.message, '[commit var]') }} + run: chmod +x create-release.sh ./create-release.sh -v ${TAG_NAME} + + - name: "create release" + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + Changes in this Release + - First Change + - Second Change + draft: false + prerelease: false + + - name: "upload release asset" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: tikz-trackschematic-${TAG_NAME}.zip + asset_name: tikz-trackschematic-${TAG_NAME}.zip + asset_content_type: application/zip + + - name: "publish release" + uses: StuYarrow/publish-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + id: ${{ steps.create_release.outputs.id }} diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 0632f47..31273e1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -33,8 +33,8 @@ jobs: - name: "setup TeX Live (via paolobrasolin)" uses: paolobrasolin/setup-texlive-action@v1 with: - profile-path: ${{ github.workspace }}/.github/tex/texlive.profile.txt - packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt + profile-path: ${{ github.workspace }}/.github/tex/minimal.profile.txt + packages-path: ${{ github.workspace }}/.github/tex/test.packages.txt - name: "install tikz-trackschematic" run: chmod +x dev-install.sh && ./dev-install.sh -b diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 049d595..34c1a8a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,8 +13,7 @@ Please note we have a code of conduct, please follow it in all your interactions variables, exposed ports, useful file locations and container parameters. 3. The versioning scheme we use is [SemVer](http://semver.org/). Increase the version numbers in the following files to the new version that this Pull Request would represent: 1. README.md - 2. doc/versionhistory.tex and recompile manual.tex & snippets.tex - 3. src/tikz-trackschematic.sty + 2. doc/versionhistory.tex 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. 5. The following versioning steps will be taken care of by the maintainer: diff --git a/create-release.sh b/create-release.sh new file mode 100755 index 0000000..80b2850 --- /dev/null +++ b/create-release.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env sh + +# Copyright (c) 2018 - 2022, Martin Scheidt (ISC license) +# Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +#### +# This script produces a .zip-file in accordance to the requirements for CTAN. +# For more information see https://ctan.org/help/upload-pkg. +#### + +# Halt on error +set -e + +## -- pass getopts + +usage() { echo "Usage: create-release.sh [-v version]"; } + +verbose=1 +batch_mode=0 + +while getopts ":v" opt; do + case ${opt} in + v ) batch_mode=1 + verbose=0 + ;; + \? ) usage + exit 1 + ;; + esac +done + +if [ "`echo -n`" = "-n" ]; then + n="" + c="\c" +else + n="-n" + c="" +fi + +if [ "$batch_mode" = 0 ]; then + echo $n "specify version ( e.g. v0.6 ): $c" + read VERSION +else + VERSION=$2 +fi + +## -- commands + +check_readme() { + # check if $VERSION is present in README.md + status=0 + grep -qs "Version ${VERSION:1}" README.md || status=1 + if [ $status = 0 ]; then + if [ $verbose = 1 ]; then + echo "Version ${VERSION:1} is present in README.md." + fi + return 0 + fi + + echo "Version ${VERSION:1} not found in README.md." + echo "Be sure to edit README.md and specify current version!" + exit 1 +} + +check_versionhistory() { + # check if $VERSION is present in doc/versionhistory.tex + status=0 + grep -qs "vhEntry{${VERSION:1}" doc/versionhistory.tex || status=1 + if [ $status = 0 ]; then + if [ $verbose = 1 ]; then + echo "Version ${VERSION:1} is present in versionhistory.tex." + fi + return 0 + fi + + echo "Version ${VERSION:1} not found in versionhistory.tex." + echo "Be sure to edit versionhistory.tex and specify current version!" + exit 1 +} + +## -- creating the release + +## check if $VERSION is present in README.md and versionhistory.tex +check_readme +check_versionhistory + +## extract DATE from versionhistory.tex +LINE=$(grep "vhEntry{${VERSION:1}" doc/versionhistory.tex) +DATEISO=$(echo $LINE | egrep -o '\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])') +# DATE=$(echo $DATEISO | sed -e "s|-|\\\/|g") # with escape character for sed +# DATE=$(date "+%Y\/%m\/%d") # with escape character for sed + +## update version number and delete line below in tikz-trackschematic.sty +sed -i '.backup' -e "s|VERSIONDATE|$DATEISO|g" src/tikz-trackschematic.sty +sed -i '' -e "/create-release/c\ " src/tikz-trackschematic.sty + + +## (OPTIONAL) recompile manual.tex, examples, symboly_table and snippets.tex` + + +## create zip-archive +# create temporary folder +TMP="tikz-trackschematic-$VERSION" +mkdir $TMP + +# copy README and .sty-file +cp README.md $TMP/README.md +cp doc/tikz-trackschematic-documentation.sty $TMP/ + +# copy and rename documentation +cp doc/manual.pdf $TMP/tikz-trackschematic.pdf +cp doc/manual.tex $TMP/tikz-trackschematic.tex +cp doc/snippets.pdf $TMP/tikz-trackschematic-snippets.pdf +cp doc/snippets.tex $TMP/tikz-trackschematic-snippets.tex +cp doc/symbology_table.pdf $TMP/tikz-trackschematic-symbology-table.pdf +cp doc/symbology_table.tex $TMP/tikz-trackschematic-symbology-table.tex +mkdir $TMP/tikz-trackschematic-examples +mkdir $TMP/tikz-trackschematic-snippets +cp -R doc/examples/* $TMP/tikz-trackschematic-examples/ +cp -R doc/snippets/* $TMP/tikz-trackschematic-snippets/ +if [ $verbose = 1 ]; then + echo "copied documentation" +fi + +# copy src-files +for SRC in src/*; do + cp $SRC $TMP +done + +if [ $verbose = 1 ]; then + echo "copied src-files" +fi + +# zip package +zip -r $TMP.zip $TMP/* + +# cleanup +rm -rf $TMP/* +rmdir $TMP diff --git a/create_ctan-package.sh b/create_ctan-package.sh deleted file mode 100755 index a12398d..0000000 --- a/create_ctan-package.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env sh - -# Copyright (c) 2018 - 2022, Martin Scheidt (ISC license) -# Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -echo "specify version ( e.g. v0.6 ):" -read VERSION - -# create temporary folder -mkdir tikz-trackschematic-$VERSION - -# copy README and .sty-file -cp README.md tikz-trackschematic-$VERSION/README.md -cp doc/tikz-trackschematic-documentation.sty tikz-trackschematic-$VERSION/tikz-trackschematic-documentation.sty - -# copy and rename documentation -cp doc/manual.pdf tikz-trackschematic-$VERSION/tikz-trackschematic.pdf -cp doc/manual.tex tikz-trackschematic-$VERSION/tikz-trackschematic.tex -cp doc/snippets.pdf tikz-trackschematic-$VERSION/tikz-trackschematic-snippets.pdf -cp doc/snippets.tex tikz-trackschematic-$VERSION/tikz-trackschematic-snippets.tex -mkdir tikz-trackschematic-$VERSION/tikz-trackschematic-examples -mkdir tikz-trackschematic-$VERSION/tikz-trackschematic-snippets -cp -R doc/examples/* tikz-trackschematic-$VERSION/tikz-trackschematic-examples -cp -R doc/snippets/* tikz-trackschematic-$VERSION/tikz-trackschematic-snippets - -# copy src -cp src/tikz-trackschematic.sty tikz-trackschematic-$VERSION/tikz-trackschematic.sty -cp src/tikzlibrarytrackschematic.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.code.tex -cp src/tikzlibrarytrackschematic.constructions.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.constructions.code.tex -cp src/tikzlibrarytrackschematic.electrics.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.electrics.code.tex -cp src/tikzlibrarytrackschematic.measures.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.measures.code.tex -cp src/tikzlibrarytrackschematic.topology.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.topology.code.tex -cp src/tikzlibrarytrackschematic.trafficcontrol.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.trafficcontrol.code.tex -cp src/tikzlibrarytrackschematic.vehicles.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.vehicles.code.tex -cp src/tikzlibrarytrackschematic.symbology.code.tex tikz-trackschematic-$VERSION/tikzlibrarytrackschematic.symbology.code.tex - -# zip package -zip -r tikz-trackschematic-$VERSION.zip tikz-trackschematic-$VERSION/* - -#cleanup -rm -rf tikz-trackschematic-$VERSION/* -rmdir tikz-trackschematic-$VERSION \ No newline at end of file diff --git a/doc/symbology_table.pdf b/doc/symbology-table.pdf similarity index 100% rename from doc/symbology_table.pdf rename to doc/symbology-table.pdf diff --git a/doc/symbology_table.tex b/doc/symbology-table.tex similarity index 100% rename from doc/symbology_table.tex rename to doc/symbology-table.tex diff --git a/src/tikz-trackschematic.sty b/src/tikz-trackschematic.sty index 7f4f65a..b2561da 100644 --- a/src/tikz-trackschematic.sty +++ b/src/tikz-trackschematic.sty @@ -5,8 +5,8 @@ % Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. % \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{tikz-trackschematic}[2022/02/02 tikz-trackschematic]% -% +\ProvidesPackage{tikz-trackschematic}[VERSIONDATE tikz-trackschematic]% +% create-release.sh will remove this line and ^--VERSIONDATE will be replaced %%%%%%%%%%%%%%% % Package options %%%%%%%%%%%%%%%