-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecfbf72
commit fb48228
Showing
2 changed files
with
190 additions
and
36 deletions.
There are no files selected for viewing
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
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
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/ |