Release for bug fix #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release for bug fix | |
on: | |
workflow_dispatch: | |
jobs: | |
release-bug-fix: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" | |
steps: | |
- name: Setup Git repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Update Ubuntu packages | |
run: sudo apt-get update | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'release' | |
- name: Setup pandoc | |
uses: r-lib/actions/setup-pandoc@v2 | |
- name: Install rmarkdown | |
run: install.packages("rmarkdown") | |
shell: Rscript {0} | |
# Get previous version of user manual and create the next version | |
- name: Application Version Bug Fix | |
id: version | |
run: | | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
old="$(git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1))" | |
echo ${old} | |
# Extract version components | |
major=$(echo "${old}" | awk -F. '{print $1}') | |
minor=$(echo "${old}" | awk -F. '{print $2}') | |
patch=$(echo "${old}" | awk -F. '{print $3}') | |
increment=$(echo "${old}" | awk -F. '{print $4}') | |
if echo "${increment}" | grep -E ^\-?[0-9]?\.?[0-9]+$ | |
then | |
increment=$((increment + 1)) | |
else | |
increment=1 | |
fi | |
# Construct new version string | |
new_version="${major}.${minor}.${patch}.$increment" | |
echo "version=${new_version}" >> "$GITHUB_ENV" | |
echo "version=${new_version}" >> "$GITHUB_OUTPUT" | |
echo ${new_version} | |
# Create version.txt to use when changing the version in the tex file | |
- name: Create version.txt | |
run: | | |
echo ${{ steps.version.outputs.version }} > version.txt | |
# Update version and date in SS330_User_Manual.tex | |
- name: Update version and date in manual | |
run: | | |
version <- readLines("version.txt", encoding = "UTF-8") | |
version <- gsub("v", "", version) | |
manual_tex <- readLines("SS330_User_Manual.tex") | |
vers_vec <- paste0(c("[0-9].[0-9][0-9].[0-9][0-9]","[0-9].[0-9][0-9].[0-9][0-9].[0-9]"), collapse = "|") | |
manual_tex[grep("Version", manual_tex)] <- gsub( | |
pattern = vers_vec, | |
replacement = version, | |
x = manual_tex[grep(pattern = "Version", x = manual_tex)] | |
) | |
date_line <- grep(pattern = "date\\{", x = manual_tex) | |
todays_date <- format(x = Sys.Date(), "%B %d, %Y") | |
manual_tex[date_line] <- gsub( | |
pattern = "\\{[A-Za-z0-9, ]+", | |
replacement = paste0("{", todays_date), | |
x = manual_tex[date_line]) | |
writeLines(text = manual_tex, con = "SS330_User_Manual.tex") | |
shell: Rscript {0} | |
- name: Remove version.txt before committing | |
run: rm version.txt | |
# Create HTML | |
- name: Convert tex to html | |
run: pandoc SS330_User_Manual.tex -s -o SS330_User_Manual.html --toc --embed-resources --standalone --mathjax --default-image-extension=png --number-sections --citeproc --variable linkcolor=#0033CC | |
- name: Run R script to create html | |
run: | | |
source(".github/r_code/edit_html_improve_formatting.R") | |
writeLines(html_txt, "docs/SS330_User_Manual_release.html") | |
file.remove("SS330_User_Manual.html") | |
shell: Rscript {0} | |
# Commit tex and html changes | |
- name: Commit changes of tex file version and html in docs folder to repo | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: 'update tex file version and html in docs' | |
# Create PDF | |
- name: Compile LaTeX document | |
uses: xu-cheng/latex-action@v2 | |
with: | |
root_file: SS330_User_Manual.tex | |
latexmk_use_lualatex: true | |
# Create Release | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ steps.version.outputs.version }} | |
release_name: ${{ steps.version.outputs.version }} Docs | |
draft: false | |
prerelease: false | |
body: SS3 User Manual for the ${{ steps.version.outputs.version }} Stock Synthesis release. | |
# Add PDF as artifact for release | |
- name: Upload release artifact - pdf manual | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./SS330_User_Manual.pdf | |
asset_name: SS330_User_Manual.pdf | |
asset_content_type: application/pdf | |
# Render user manuals to github pages | |
- name: Deploy to GitHub pages | |
uses: JamesIves/github-pages-deploy-action@4.1.4 | |
with: | |
branch: gh-pages | |
folder: docs/ |