-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from alephnull7/master
Version 1.0.7 changes documentation & GitHub action workflow for automated releases
- Loading branch information
Showing
15 changed files
with
206 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^tests/ | ||
^\.github/ |
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,26 @@ | ||
import os | ||
import sys | ||
import re | ||
|
||
|
||
def main(): | ||
r_directory = "../../R/" | ||
current_timestamp = sys.argv[1] | ||
version_comment = f"#version=\"{current_timestamp}\"\n" | ||
|
||
for filename in os.listdir(r_directory): | ||
file_path = os.path.join(r_directory, filename) | ||
|
||
if os.path.isfile(file_path): | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
if len(lines) >= 4 and re.match("^#version", lines[3]): | ||
lines[3] = version_comment | ||
with open(file_path, 'w') as file: | ||
file.writelines(lines) | ||
print(f"Version comment updated to current UTC: {filename}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,155 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
paths: ["CHANGELOG.md"] | ||
|
||
name: create-release | ||
|
||
jobs: | ||
release-documentation: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
CHANGELOG: "CHANGELOG.md" | ||
DESCRIPTION: "DESCRIPTION" | ||
outputs: | ||
version: ${{ steps.extract-version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Extract release version from first level 4 heading | ||
id: extract-version | ||
run: | | ||
version=$(grep -oP '####[^0-9]*\K\d+\.\d+\.\d+' -m 1 $CHANGELOG) | ||
echo "version=$version" >> $GITHUB_ENV | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
echo "Version: $version" | ||
- name: Get current UTC timestamp | ||
id: get-timestamp | ||
run: | | ||
timestamp=$(date -u +"%Y.%m.%d.%H%M") | ||
echo "timestamp=$timestamp" >> $GITHUB_ENV | ||
echo "Timestamp: $timestamp" | ||
- name: Standardize first level 4 heading | ||
id: update-change-header | ||
run: | | ||
timestamp=$(echo "${{ env.timestamp }}" | awk -F'.' '{print $1"."$2"."$3}') | ||
sed -i "0,/^####.*$/s/^####.*$/#### Version ${{ env.version }} \($timestamp\)/" $CHANGELOG | ||
echo "CHANGELOG Timestamp: $timestamp" | ||
- name: Update DESCRIPTION `Version` and `Date` | ||
id: update-description | ||
run: | | ||
timestamp=$(echo "${{ env.timestamp }}" | awk -F'.' '{print $1"-"$2"-"$3}') | ||
sed -i "s|^Date:.*$|Date: $timestamp|" $DESCRIPTION | ||
sed -i "s|^Version:.*$|Version: ${{ env.version }}|" $DESCRIPTION | ||
echo "DESCRIPTION Timestamp: $timestamp" | ||
- name: Update `version` comments on R files | ||
id: update-r-version-comment | ||
run: | | ||
cd .github/scripts | ||
chmod +x update_version_tag.py | ||
python update_version_tag.py ${{ env.timestamp }} | ||
- name: Commit and push changes | ||
run: | | ||
git config --local user.name "$GITHUB_ACTOR" | ||
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
git add ./R/*.R | ||
git add DESCRIPTION | ||
git add CHANGELOG.md | ||
git commit -m "Updated documentation for release" || echo "No changes to commit" | ||
git pull --ff-only | ||
git push origin | ||
release-build: | ||
runs-on: ubuntu-latest | ||
needs: release-documentation | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
CHANGELOG: "CHANGELOG.md" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-tinytex@v2 | ||
- run: tlmgr --version | ||
|
||
- name: Install additional LaTeX packages | ||
run: | | ||
tlmgr install preprint | ||
tlmgr install listings | ||
tlmgr install tcolorbox | ||
tlmgr install pgf | ||
tlmgr install environ | ||
tlmgr install tikzfill | ||
tlmgr install pdfcol | ||
tlmgr install grfext | ||
tlmgr list --only-installed | ||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: "release" | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- name: Build R package | ||
run: | | ||
R CMD build --compact-vignettes=gs+qpdf . | ||
tar_file="$(find . -maxdepth 1 -type f -name '*.tar.gz' -print -quit | sed 's|^\./||')" | ||
artifacts="artifacts" | ||
mkdir $artifacts | ||
mv $tar_file "$artifacts/" | ||
echo "tar_file=$artifacts/$tar_file" >> $GITHUB_ENV | ||
echo "asset_name=$tar_file" >> $GITHUB_ENV | ||
- name: Make release properties | ||
id: release-fields | ||
run: | | ||
version="${{ needs.release-documentation.outputs.version }}" | ||
echo "version=$version" >> $GITHUB_ENV | ||
echo "Version: $version" | ||
tag="v${version}" | ||
echo "tag=$tag" >> $GITHUB_ENV | ||
echo "Tag: $tag" | ||
name="Version ${version}" | ||
echo "name=$name" >> $GITHUB_ENV | ||
echo "Name: $name" | ||
body="$(awk '/^\*.*$/{print; next} /^####/{count++; if(count==2) exit}' $CHANGELOG)" | ||
echo "body<<EOF" >> "$GITHUB_ENV" | ||
echo "$body" >> "$GITHUB_ENV" | ||
echo "EOF" >> "$GITHUB_ENV" | ||
echo "Body: $body" | ||
- name: Create Release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.tag }} | ||
release_name: ${{ env.name }} | ||
draft: false | ||
prerelease: false | ||
body: | | ||
${{ env.body }} | ||
- name: Upload Release Asset | ||
id: 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: ${{ env.tar_file }} | ||
asset_name: ${{ env.asset_name }} | ||
asset_content_type: application/gzip |
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
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
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
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
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
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