Saltstack Official Apache Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

pre-commit_semantic-release.sh 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/sh
  2. ###############################################################################
  3. # (A) Update `FORMULA` with `${nextRelease.version}`
  4. ###############################################################################
  5. sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA
  6. ###############################################################################
  7. # (B) Use `m2r` to convert automatically produced `.md` docs to `.rst`
  8. ###############################################################################
  9. # Install `m2r`
  10. pip3 install m2r
  11. # Copy and then convert the `.md` docs
  12. cp ./*.md docs/
  13. cd docs/ || exit
  14. m2r --overwrite ./*.md
  15. # Change excess `H1` headings to `H2` in converted `CHANGELOG.rst`
  16. sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst
  17. sed -i -e '1,4s/-/=/g' CHANGELOG.rst
  18. # Use for debugging output, when required
  19. # cat AUTHORS.rst
  20. # cat CHANGELOG.rst
  21. # Return back to the main directory
  22. cd ..
  23. ###############################################################################
  24. # (C) Make all adjustments related to the Antora-based documentation
  25. # This needs to run after the conversion to `.rst` since it uses
  26. # those files to convert to `.adoc`
  27. ###############################################################################
  28. # Update `docs/antora.yml` with `${nextRelease.version}`
  29. sed -i -e "/^\(version: '\).*\('\)$/s//\1${1}\2/" docs/antora.yml
  30. # Convert the files from `.rst` to `.adoc` using `pandoc`
  31. FROM=rst && FN=CHANGELOG && pandoc -t asciidoctor -f ${FROM} -o docs/modules/ROOT/pages/${FN}.adoc docs/${FN}.${FROM}
  32. FROM=rst && FN=AUTHORS && pandoc -t asciidoctor -f ${FROM} -o docs/modules/ROOT/pages/${FN}.adoc docs/${FN}.${FROM}
  33. FROM=rst && FN=README && pandoc -t asciidoctor -f ${FROM} -o docs/modules/ROOT/pages/${FN}.adoc docs/${FN}.${FROM}
  34. # Adjust `CHANGELOG.adoc`
  35. ADOC="docs/modules/ROOT/pages/CHANGELOG.adoc"
  36. # Fix links to avoid issue with `...` in URL
  37. # Also ensure each of these links opens in a new tab
  38. sed -i -e '/^\(=== \)\(https.*\)\(\[.*\)\(]\)/s//\1link:++\2++\3^\4/' "${ADOC}"
  39. # Open other standard links in new tabs
  40. sed -i -e '/^\((https.*\)\(]\)/s//\1^\2/' "${ADOC}"
  41. sed -i -e '/^\(https.*\)\(]\)/s//\1^\2/' "${ADOC}"
  42. # And other non-standard links
  43. # shellcheck disable=SC2016
  44. sed -i -e '\_^\((https.*/commit/\)\(.......\)\()\)$_s__\1\2[\2^]\3_' "${ADOC}"
  45. # Fix headings throughout file
  46. sed -i -e '/^=/s///' "${ADOC}"
  47. # Fix `[skip ci]` on line by itself
  48. sed -i -e '/^\[skip ci]$/s// &/' "${ADOC}"
  49. # Fix what looks like Asciidoctor variables, i.e. in curly braces `{...}`
  50. sed -i -e '/{\w\+}/s//\\&/' "${ADOC}"
  51. # Add `:sectnums!:` directly after the title (the blank line in-between is necessary)
  52. sed -i -e '2 i \\n:sectnums!:' "${ADOC}"
  53. # Adjust `AUTHORS.adoc`
  54. ADOC="docs/modules/ROOT/pages/AUTHORS.adoc"
  55. # Fix the heading
  56. sed -i -e '/^=/s///' "${ADOC}"
  57. # Run three times to get all four lines joined
  58. # (most entries only need two joins but that's dealt with below)
  59. sed -i -e '/^|:raw-html-m2r/N;s/\n/ /' "${ADOC}"
  60. sed -i -e '/^|:raw-html-m2r/N;s/\n/ /' "${ADOC}"
  61. sed -i -e '/^|:raw-html-m2r/N;s/\n/ /' "${ADOC}"
  62. # Add blank line in-between
  63. sed -i -e '/^|:raw-html-m2r/{G;}' "${ADOC}"
  64. # Clear up any double-blank lines introduced
  65. sed -i -e '/^$/N;/\n$/D' "${ADOC}"
  66. # Split the lines again on the table delimeter
  67. sed -i -e '/^|:raw-html-m2r/s/ |/\n|/g' "${ADOC}"
  68. # Fix the `raw-html-m2r` to link to the GitHub avatar images correctly
  69. sed -i -e "/^\(|\):raw-html-m2r.*src='\(.*\)' width='\(.*\)' height='\(.*\)' alt='\(.*\)'.*/s//\1image::\2[\5,\3,\4]/" "${ADOC}"
  70. # Reduce the table boundary markers
  71. sed -i -e '/^|===.*/s//|===/' "${ADOC}"
  72. # Reduce the table boundary markers
  73. sed -i -e '/^|Avatar |Contributor |Contributions/s//^.^|Avatar\n<.^|Contributor\n^.^|Contributions\n/' "${ADOC}"
  74. # Fix the table heading
  75. sed -i -e '/^\[cols=".*/s//.List of contributors\n[format="psv", separator="|", options="header", cols="^.<30a,<.<40a,^.<40d", width="100"]/' "${ADOC}"
  76. # Open links in new tab
  77. sed -i -e '/^\(|https.*\)\(]\)/s//\1^\2/' "${ADOC}"
  78. # Likewise for footer links
  79. sed -i -e '/\(\[forked version\)\(]\)/s//\1^\2/' "${ADOC}"
  80. sed -i -e '/\(\[.*maintainer\)\(]\)/s//\1^\2/' "${ADOC}"
  81. # Adjust `README.adoc`
  82. ADOC="docs/modules/ROOT/pages/README.adoc"
  83. # Fix headings throughout file
  84. sed -i -e '/^=/s///' "${ADOC}"
  85. # Delete the `[[readme]]` line
  86. sed -i -e '/^\[\[readme]]$/d' "${ADOC}"
  87. # Remove the `Table of Contents` line and the blank line after it
  88. sed -i -e '/^\*Table of Contents\*$/,+1d' "${ADOC}"
  89. # Fix the link to `CONTRIBUTING.adoc` (to the Antora-based version)
  90. # shellcheck disable=SC2016
  91. sed -i -e '/^Please see `How to contribute <CONTRIBUTING>` for more details.$/s//Please see\nxref:main::CONTRIBUTING.adoc[How to contribute]\nfor more details./' "${ADOC}"
  92. # Fix the link to `CONTRIBUTING.adoc` (to the Antora-based version) -- based on `.github` repo
  93. sed -i -e '\_https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst_s__xref:main::CONTRIBUTING.adoc_' "${ADOC}"
  94. # Fix the link to `map.jinja.adoc` (to the Antora-based version)
  95. sed -i -e '/^\* link:map.jinja.rst/s//* xref:main::map.jinja.adoc/' "${ADOC}"
  96. # Fix link: `#_special_notes`
  97. sed -i -e '/#special-notes/s//#_special_notes/' "${ADOC}"
  98. # Fix `sourceCode`
  99. sed -i -e '/^\(\[source,\)sourceCode,/s//\1/' "${ADOC}"
  100. # Fix source `jinja2`
  101. sed -i -e '/^\(\[source,jinja\)2/s//\1/' "${ADOC}"
  102. # Fix source `sls`
  103. sed -i -e '/^\(\[source,\)sls/s//\1yaml/' "${ADOC}"