Skip to content

Commit

Permalink
updates & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
e-perl-NOAA committed Aug 21, 2024
1 parent ecfbf72 commit fb48228
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 36 deletions.
62 changes: 26 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
- name: Convert tex to html
run: pandoc SS330_User_Manual.tex -s -o SS330_User_Manual_release.html --toc --self-contained --mathjax --default-image-extension=png --number-sections --citeproc --variable linkcolor=#0033CC
# Note: for the following R code, may be a single command to deal with the double header issue before rendering.

# Create user_manual_name.txt to user for the name of the html file
# (will be release here but will not have release for the build-ss3-manual.yml)
- name: Create user_manual_name.txt
Expand All @@ -89,48 +90,36 @@ jobs:
source("Rcode/edit_html_improve_formatting.R")
shell: Rscript {0}

- name: Commit html of manual to docs folder
# Update the version in index.md [this will need to change when website is updated]
- name: Update version in index.md
run: |
version <- readLines("version.txt", encoding = "UTF-8")
index <- readLines("docs/index.md", encoding = "UTF-8")
index <- gsub("v[0-9]\\.[0-9]{2}\\.[0-9]{2}", version, index)
writeLines(index, "docs/index.md")
shell: Rscript {0}

# Commit changes to the version in index.md and html in docs to the repository
- name: Commit changes made to index.md and html in docs
uses: EndBug/add-and-commit@v9
with:
add: './docs/SS330_User_Manual_release.html'
message: 'update manual html in docs'
message: 'update html in docs and index version'

# PDF Portion
- name: remove rendered file, check that is gone.
run: |
rm -rf SS330_User_Manual.pdf
ls
# - name: add lua filter to the repository
# run: wget https://raw.githubusercontent.com/klpn/accpdf/master/common/tagged-filter.lua
# - name: add lua filter to the repository
# run: wget https://raw.githubusercontent.com/klpn/accpdf/master/common/tagged-filter.lua

- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: SS330_User_Manual.tex
#args: --lua-filter=tagged-filter.lua
latexmk_use_lualatex: true

# Change name of pdf file to include "_release"
- name: Add _release to pdf file name
run: |
mv SS330_User_Manual.pdf SS330_User_Manual_release.pdf
# Update the version in index.md [this will need to change when website is updated]
- name: Update version in index.md
run: |
version <- readLines("version.txt", encoding = "UTF-8")
index <- readLines("docs/index.md", encoding = "UTF-8")
index <- gsub("v[0-9]\\.[0-9]{2}\\.[0-9]{2}", version, index)
writeLines(index, "docs/index.md")
shell: Rscript {0}

# Commit changes to the version in index.md to the repository
- name: Commit changes made to index.md
uses: EndBug/add-and-commit@v9
with:
add: 'docs/index.md'
message: 'update index version'

# Create Release
- name: Create Release
id: create_release
Expand All @@ -140,24 +129,25 @@ jobs:
release_name: ${{ steps.version.outputs.version }} Docs
draft: false
prerelease: false
body: Documentation, including the user manual, for the ${{ steps.version.outputs.version }} Stock Synthesis release.

# Add html as artifact for release
# Could change link in index for html to asset location so don't need to add html to docs folder
- name: Upload release artifact - html manual
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./SS330_User_Manual_release.html
asset_name: SS330_User_Manual_release.html
asset_content_type: application/html
# - name: Upload release artifact - html manual
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./SS330_User_Manual_release.html
# asset_name: SS330_User_Manual_release.html
# asset_content_type: application/html

# 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_release.pdf
asset_name: SS330_User_Manual_release.pdf
asset_path: ./SS330_User_Manual.pdf
asset_name: SS330_User_Manual.pdf
asset_content_type: application/pdf

# Render github pages
Expand Down
164 changes: 164 additions & 0 deletions .github/workflows/release_bug_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Release for bug fix

on:
# push:
# branches: [auto-release-workflows]
workflow_dispatch:

jobs:

release-for-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

- 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 and then create the next version
- name: Application Version
id: version
uses: paulhatch/[email protected]
with:
tag_prefix: "v"
version_format: "${major}.${minor}.${patch}.${bugfix}"

# Create version.txt to use when changing the version in the index.md
- 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")
manual_tex <- readLines("SS330_User_Manual.tex")
manual_tex[grep("Version", manual_tex)] <- gsub(
pattern = "[0-9].[0-9][0-9].[0-9][0-9]",
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: Commit date and version changes in SS330_User_Manual.tex
uses: EndBug/add-and-commit@v9
with:
add: './docs/SS330_User_Manual.tex'
message: 'release: update version and date in manual'


# HTML Portion
- name: Convert tex to html
run: pandoc SS330_User_Manual.tex -s -o SS330_User_Manual_release.html --toc --self-contained --mathjax --default-image-extension=png --number-sections --citeproc --variable linkcolor=#0033CC
# Note: for the following R code, may be a single command to deal with the double header issue before rendering.

# Create user_manual_name.txt to user for the name of the html file
# (will be release here but will not have release for the build-ss3-manual.yml)
- name: Create user_manual_name.txt
run: |
name_txt <- file("user_manual_name.txt")
writeLines("SS330_User_Manual_release.html", name_txt)
close(name_txt)
shell: Rscript {0}

- name: Run R script to create html
run: |
source("Rcode/edit_html_improve_formatting.R")
shell: Rscript {0}

# Update the version in index.md [this will need to change when website is updated]
- name: Update version in index.md
run: |
version <- readLines("version.txt", encoding = "UTF-8")
index <- readLines("docs/index.md", encoding = "UTF-8")
index <- gsub("v[0-9]\\.[0-9]{2}\\.[0-9]{2}", version, index)
writeLines(index, "docs/index.md")
shell: Rscript {0}

# Commit changes to the version in index.md and html in docs to the repository
- name: Commit changes made to index.md and html in docs
uses: EndBug/add-and-commit@v9
with:
message: 'update html in docs and index version'

# PDF Portion
- name: remove rendered file, check that is gone.
run: |
rm -rf SS330_User_Manual.pdf
ls
# - name: add lua filter to the repository
# run: wget https://raw.githubusercontent.com/klpn/accpdf/master/common/tagged-filter.lua

- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: SS330_User_Manual.tex
#args: --lua-filter=tagged-filter.lua
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: Documentation, including the user manual, for the ${{ steps.version.outputs.version }} Stock Synthesis release.

# Add html as artifact for release
# Could change link in index for html to asset location so don't need to add html to docs folder
# - name: Upload release artifact - html manual
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./SS330_User_Manual_release.html
# asset_name: SS330_User_Manual_release.html
# asset_content_type: application/html

# 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 github pages
- name: render the rmd files
run: |
rmarkdown::render("User_Guides/ss3_model_tips/ss3_model_tips.Rmd", output_format = c("html_document", "pdf_document"), output_dir = "docs")
rmarkdown::render("User_Guides/getting_started/Getting_Started_SS3.Rmd", output_format = c("html_document", "pdf_document"), output_dir = "docs")
shell: Rscript {0}

- name: Deploy to GitHub pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs/

0 comments on commit fb48228

Please sign in to comment.