Skip to content

streamlinging version release #1

streamlinging version release

streamlinging version release #1

Workflow file for this run

# Workflow triggered when we have a new release candidate
# This action is adapted from https://github.com/t4d-gmbh/stubbed_versioning
name: Publish a version
on:
pull_request:
types:
- closed
env:
LABEL_PUBLISHED: 'release::published'
jobs:
build-release-content:
if: ${{ github.event.pull_request.merged && startsWith(github.head_ref, 'release-') }}
runs-on: ubuntu-latest

Check failure on line 16 in .github/workflows/publish_version.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish_version.yml

Invalid workflow file

You have an error in your yaml syntax on line 16
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}
# TODO: add abn.tar.gz as artifact
release-version:
needs: build-release-content
if: ${{ github.event.pull_request.merged && startsWith(github.head_ref, 'release-') }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
repository-projects: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
EVENT: ${{ github.event.number }} # This is either the issue or pr
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# check if the pr is labeled as published already
- name: Check if the pull request is labeled with ${{ env.LABEL_PUBLISHED }}
id: published
run: |
if $( gh pr view ${{ env.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: Attempt to create label ${{ env.LABEL_PUBLISHED }}
if: ${{ steps.published.outputs.labeled == 'false' }}
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: Get the version to release
if: ${{ steps.published.outputs.labeled == 'false' }}
id: release_version
run: |
git fetch --filter=tree:0 origin +refs/tags/*:refs/tags/*
echo "VERSION=$(echo ${{ github.head_ref }}|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
- name: Remove previous releases of the target tag, if existing
if: ${{ steps.published.outputs.labeled == 'false' }}
run: |
if script -q -e -c "gh release view ${{ steps.release_version.outputs.version }}"; 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
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="${{ steps.release_version.outputs.previous_version }}"*/{exit}' CHANGELOG.md | head -n -1 >> body.md
- name: Create tag and release
if: ${{ steps.published.outputs.labeled == 'false' }}
run: |
gh release create ${{ steps.release_version.outputs.version }} \
--target ${{ github.event.pull_request.head.sha }} \
--latest \
--title "${{ steps.release_version.outputs.version }}" \
--notes-file body.md \
--repo ${{ env.OWNER }}/${{ env.REPO }}
- name: Adding the label ${{ env.LABEL_PUBLISHED }}
if: ${{ steps.published.outputs.labeled == 'false' }}
run: |
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_PUBLISHED }} --repo ${{ env.OWNER }}/${{ env.REPO }}
shell: bash
# TODO: get artifact from previous job and add it to the release
# - name: Upload additional artifacts to the release
# run: |
# gh release upload ${{ steps.release_version.outputs.version }} \
# some_file.md \
# other_file.md \
# --clobber
# --repo ${{ env.OWNER }}/${{ env.REPO }}