Skip to content

minor changes

minor changes #164

Workflow file for this run

name: Generate PDF on Release
on:
release:
types: [published]
push:
branches:
- dev
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 1.1.0)'
required: true
default: '1.1.0'
jobs:
generate-pdf:
runs-on: ubuntu-latest
name: Generate PDF specification
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || github.ref }}
fetch-depth: 0
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
- name: Install Asciidoctor PDF
run: |
gem install asciidoctor
gem install asciidoctor-pdf
gem install rouge
- name: Get version number
id: version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
# Extract version from tag (remove 'v' prefix if present)
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/dev" ]; then
# For dev branch pushes, use dev suffix
VERSION="1.1.0-dev"
else
VERSION="${{ github.event.inputs.version }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Generate PDF
run: |
VERSION="${{ steps.version.outputs.version }}"
asciidoctor-pdf \
-a pdf-themesdir=site/pdf-theme \
-a pdf-theme=sdrf-theme \
-a pdf-fontsdir=GEM_FONTS_DIR \
-a allow-uri-read \
-a source-highlighter=rouge \
-a toc \
-a toclevels=3 \
-a sectnums \
-a revnumber=$VERSION \
-a revdate=$(date +%Y-%m-%d) \
-o "psi-document/sdrf-proteomics-specification-v${VERSION}.pdf" \
sdrf-proteomics/README.adoc
- name: Upload PDF as release asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: psi-document/sdrf-proteomics-specification-v${{ steps.version.outputs.version }}.pdf
asset_name: sdrf-proteomics-specification-v${{ steps.version.outputs.version }}.pdf
asset_content_type: application/pdf
- name: Determine target branch
id: target-branch
run: |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/dev" ]; then
echo "branch=dev" >> $GITHUB_OUTPUT
else
echo "branch=master" >> $GITHUB_OUTPUT
fi
- name: Commit and push PDF to repository
run: |
VERSION="${{ steps.version.outputs.version }}"
TARGET_BRANCH="${{ steps.target-branch.outputs.branch }}"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Check if PDF was generated
if [ -f "psi-document/sdrf-proteomics-specification-v${VERSION}.pdf" ]; then
echo "PDF generated successfully: psi-document/sdrf-proteomics-specification-v${VERSION}.pdf"
git add "psi-document/sdrf-proteomics-specification-v${VERSION}.pdf"
git commit -m "Add PDF specification v${VERSION}" || echo "No changes to commit"
git push origin HEAD:${TARGET_BRANCH}
else
echo "ERROR: PDF was not generated!"
exit 1
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: specification-pdf
path: psi-document/sdrf-proteomics-specification-v${{ steps.version.outputs.version }}.pdf