fixing several wrong varible names #19
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
# Workflow triggered when we have a new release candidate | |
# This action is adapted from https://github.com/t4d-gmbh/stubbed_versioning | |
name: Enforce release from release- branch | |
on: | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
# The tag name needs to be of the form <nbr>.<nbr>.<nbr> | |
env: | |
LABEL_PUBLISHED: 'release::published' | |
BUILD_LOC: "./build" | |
DOC_LOC: "./docs" | |
jobs: | |
# NOTE: This workflow only runs if a release- branch has an open pull request | |
associated_pr: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OWNER: ${{ github.repository_owner }} | |
REPO: ${{ github.event.repository.name }} | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
outputs: | |
event: ${{ steps.get_pr.outputs.pr }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # NOTE: This might be needed to assert that we get the full history | |
# for the changelog. | |
# get the related pull request | |
- name: Determine associated Pull request | |
id: get_pr | |
run: | | |
echo "PR=`echo $(gh pr list --repo ${{ env.OWNER }}/${{ env.REPO }} --json 'number,headRefName'|jq --arg NAME ${{ github.ref_name }} '.[] | select(.headRefName | contains($NAME)) | .number')`" >> $GITHUB_OUTPUT | |
build-release-content: | |
runs-on: ubuntu-latest | |
needs: | |
- associated_pr | |
container: | |
image: ${{ vars.CONTAINER_SOURCE }}/debian/gcc/release/abn:latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create build location | |
run: | | |
mkdir ${{ env.BUILD_LOC }} | |
shell: bash | |
- name: Disable renv | |
run: | | |
renv::deactivate() | |
shell: Rscript {0} | |
- name: Change permissions of configure | |
run: | | |
chmod +x configure | |
shell: bash | |
- name: Build the package | |
run: | | |
devtools::build(pkg = '.', path = '${{ env.BUILD_LOC }}/abn.tar.gz') | |
shell: Rscript {0} | |
- name: Upload the built package as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: ${{ env.BUILD_LOC }}/abn.tar.gz | |
build-pkgdown-content: | |
runs-on: ubuntu-latest | |
needs: | |
- associated_pr | |
# Only restrict concurrency for non-PR jobs | |
concurrency: | |
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
contents: write | |
id-token: write | |
pages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: any::pkgdown, local::. | |
needs: website | |
# TODO: delete this | |
- name: Show NEWS.md content | |
run: | | |
cat NEWS.md | |
- name: Build site | |
run: | | |
pkgdown::build_site_github_pages(dest_dir= "${{ env.DOC_LOC }}", new_process = FALSE, install = FALSE) | |
shell: Rscript {0} | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload pkgdown artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: ${{ env.DOC_LOC }}/ | |
release-version: | |
# NOTE: Currently this workflow only runs if a release- branch has an open pull request | |
needs: | |
- associated_pr | |
- build-release-content | |
- build-pkgdown-content | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OWNER: ${{ github.repository_owner }} | |
REPO: ${{ github.event.repository.name }} | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # NOTE: This might be needed to assert that we get the full history | |
# for the changelog. | |
- name: Attempt to create label ${{ env.LABEL_PUBLISHED }} | |
if: ${{ needs.associated_pr.outputs.event }} | |
id: present_label | |
run: | | |
gh label create ${{ env.LABEL_PUBLISHED }} --repo ${{ env.OWNER }}/${{ env.REPO }} | |
continue-on-error: true # make sure the next steps run also on failure | |
- name: Check if the pull request is labeled with ${{ env.LABEL_PUBLISHED }} # 2 | |
id: published | |
run: | | |
if $( gh pr view ${{ needs.associated_pr.outputs.event }} --repo ${{ env.OWNER }}/${{ env.REPO }} --json "labels" --jq ".[].[].name" | grep --quiet ${{ env.LABEL_PUBLISHED }}); then | |
echo "LABELED=true" >> $GITHUB_OUTPUT | |
else | |
echo "LABELED=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Get the version to release # 2 | |
if: ${{ (steps.published.outputs.labeled == 'false') }} | |
id: release_version | |
run: | | |
git fetch --filter=tree:0 origin +refs/tags/*:refs/tags/* | |
echo "VERSION=$(echo ${{ github.ref_name }}|grep -Eo '[0-9]+.[0-9]+.[0-9]+')" >> $GITHUB_OUTPUT | |
echo "PREVIOUS_VERSION=`echo $(git tag --list | grep -E '[0-9]+.[0-9]+.[0-9]+$' | tail -n1)`" >> $GITHUB_OUTPUT | |
cat $GITHUB_OUTPUT | |
- name: Remove previous releases of the target tag, if existing # 2 | |
if: ${{ (steps.published.outputs.labeled == 'false') }} | |
run: | | |
if script -q -e -c "gh release view ${{ steps.release_version.outputs.version }} --repo ${{ env.OWNER }}/${{ env.REPO }}"; then | |
# removing previous release along with associated tag | |
gh release delete ${{ steps.release_version.outputs.version }} \ | |
--cleanup-tag -y \ | |
--repo ${{ env.OWNER }}/${{ env.REPO }} | |
else | |
# non-exist | |
echo "No trace of a previous release." | |
fi | |
- name: Prepare Release note # 2 | |
if: ${{ (steps.published.outputs.labeled == 'false') }} | |
# this gets the first the changes to the previous clean tag (including manual edits) | |
run: | | |
awk '/<a name="${{ steps.release_version.outputs.version }}".*/{a=1};a;/<a name="${{ needs.release_version.outputs.previous_version }}"*/{exit}' NEWS.md | head -n -1 >> body.md | |
- name: Create tag and release # 2 | |
if: ${{ (steps.published.outputs.labeled == 'false') }} | |
run: | | |
echo $GITHUB_SHA | |
gh release create ${{ steps.release_version.outputs.version }} \ | |
--target $GITHUB_SHA \ | |
--latest \ | |
--title "${{ steps.release_version.outputs.version }}" \ | |
--notes-file body.md \ | |
--repo ${{ env.OWNER }}/${{ env.REPO }} \ | |
- name: Adding the label ${{ env.LABEL_PUBLISHED }} # 2 | |
if: ${{ (steps.published.outputs.labeled == 'false') }} | |
run: | | |
gh pr edit ${{ needs.associated_pr.outputs.event }} --add-label ${{ env.LABEL_PUBLISHED }} --repo ${{ env.OWNER }}/${{ env.REPO }} | |
shell: bash | |
- name: Get the built package | |
uses: actions/download-artifact@v4 | |
with: | |
name: | |
package | |
- name: Upload additional artifacts to the release | |
run: | | |
gh release upload ${{ steps.release_version.outputs.version }} \ | |
${{ env.BUILD_LOC }}/abn.tar.gz \ | |
--clobber | |
--repo ${{ env.OWNER }}/${{ env.REPO }} | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |