Merge pull request #102 from stocnet/develop #46
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
on: | |
push: | |
branches: | |
- main | |
name: Check and release | |
jobs: | |
build: | |
name: Build for ${{ matrix.config.os }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {os: macOS-latest, r: 'release', artifact_name: '*.tar.gz', asset_name: macOS} | |
- {os: windows-latest, r: 'release', artifact_name: '*.zip', asset_name: winOS} | |
- {os: ubuntu-latest, r: 'release', artifact_name: '*.tar.gz', asset_name: linuxOS} | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
RSPM: ${{ matrix.config.rspm }} | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
cache-version: 2 | |
needs: check, build | |
extra-packages: | | |
any::rcmdcheck | |
any::remotes | |
- uses: r-lib/actions/check-r-package@v2 | |
env: | |
_R_CHECK_FORCE_SUGGESTS_: false | |
with: | |
upload-snapshots: true | |
- name: Binary | |
run: | | |
pkgbuild::clean_dll() | |
binary <- pkgbuild::build(binary = TRUE, needs_compilation = TRUE, compile_attributes = TRUE) | |
dir.create("build") | |
file.copy(binary, "build") | |
shell: Rscript {0} | |
- name: Save binary artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.config.asset_name }} | |
path: build/ | |
- name: Calculate code coverage | |
if: runner.os == 'macOS-latest' | |
run: Rscript -e "covr::codecov()" | |
release: | |
name: Bump version and release | |
if: ${{ always() }} | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout one | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Bump version and push tag | |
id: newtag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DEFAULT_BUMP: patch | |
RELEASE_BRANCHES: main | |
- name: Checkout two | |
uses: actions/checkout@v4 | |
- name: Extract version | |
run: | | |
echo "PACKAGE_VERSION=$(grep '^Version' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV | |
echo "PACKAGE_NAME=$(grep '^Package' DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
- name: Rename binaries release | |
shell: bash | |
run: | | |
ls -R | |
cp ./macOS/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}*.tgz . | |
cp ./linuxOS/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}*.tar.gz . | |
cp ./winOS/${{ env.PACKAGE_NAME }}_${{ env.PACKAGE_VERSION }}*.zip . | |
echo "Renamed files" | |
ls manynet_* | |
- name: Create Release and Upload Assets | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.newtag.outputs.tag }} | |
name: Release ${{ steps.newtag.outputs.tag }} | |
draft: false | |
prerelease: false | |
fail_on_unmatched_files: true | |
# Specify the assets you want to upload | |
files: | | |
manynet_*.tgz | |
manynet_*.tar.gz | |
manynet_*.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
pkgdown: | |
name: Build and deploy website | |
if: ${{ always() }} | |
needs: release | |
runs-on: macOS-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
- uses: r-lib/actions/setup-pandoc@v1 | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
cache-version: 2 | |
extra-packages: | | |
any::rcmdcheck | |
any::pkgdown | |
any::rsconnect | |
needs: check | |
- name: Install package | |
run: R CMD INSTALL . | |
- name: Deploy package | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' |