Skip to content

Commit

Permalink
Make releases from workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Dec 28, 2020
1 parent 6b443de commit 9bde4ee
Showing 1 changed file with 144 additions and 11 deletions.
155 changes: 144 additions & 11 deletions .github/workflows/docs.yml
Expand Up @@ -50,13 +50,6 @@ jobs:
id: get_version
run: echo ::set-output name=VERSION::$(python -c 'print([line.split("=")[-1].strip()[1:-1] for line in open("./src/qalgebra/__init__.py", encoding="utf8").readlines() if line.startswith("__version__")][0], end="")')

- name: Get branch name
shell: bash
run: |
echo ${{ github.ref }}
echo "BRANCH_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV
cat $GITHUB_ENV
- name: Zip the HTML documentation
run: zip-folder --debug --auto-root --outfile "qalgebra-docs-${{ steps.get_version.outputs.VERSION }}.zip" docs/_build/html

Expand All @@ -67,15 +60,155 @@ jobs:
name: Upload documentation artifacts
with:
name: qalgebra-docs
# We need at least two files in the artifact to avoid a weird
# double-zip file. Hence README.md
path: |
./qalgebra-docs-${{ steps.get_version.outputs.VERSION }}.zip
./qalgebra-docs-${{ steps.get_version.outputs.VERSION }}.pdf
README.md
./qalgebra-docs-${{ steps.get_version.outputs.VERSION }}.*
create_github_release:
name: Create a Github Release
runs-on: ubuntu-18.04
# if: startsWith(github.ref, 'refs/tags/v')
needs: build_docs
steps:

- name: Checkout code
uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python 3.8
with:
python-version: 3.8

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(python -c 'print([line.split("=")[-1].strip()[1:-1] for line in open("./src/qalgebra/__init__.py", encoding="utf8").readlines() if line.startswith("__version__")][0], end="")')

- name: Get tag name
shell: bash
run: |
echo ${{ github.ref }}
echo "TAG_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV
cat $GITHUB_ENV
# - name: Check that tag is release
# run: test "v${{ steps.get_version.outputs.VERSION }}" == "${{ env.TAG_NAME }}"

- uses: actions/download-artifact@v2
name: Download qalgebra-docs artifact
with:
name: qalgebra-docs
path: _qalgebra_docs

- name: Check for html (zip) artifact
id: zip_artifact_file
run: |
echo ::set-output name=allfiles::$(ls _qalgebra_docs/*) # DEBUG
echo ::set-output name=filename::$(ls _qalgebra_docs/*.zip | head -n1)
echo ::set-output name=basename::$(basename "`ls _qalgebra_docs/*.zip | head -n1`")
- name: Check for pdf artifact
id: pdf_artifact_file
run: |
echo ::set-output name=filename::$(ls _qalgebra_docs/*.pdf | head -n1)
echo ::set-output name=basename::basename "$(ls _qalgebra_docs/*.pdf | head -n1)"
- name: Check for epub artifact
id: epub_artifact_file
run: |
echo ::set-output name=filename::$(ls _qalgebra_docs/*.epub | head -n1)
echo ::set-output name=basename::basename "$(ls _qalgebra_docs/*.epub | head -n1)"
- name: Check zip file (DEBUG)
if: ${{ steps.zip_artifact_file.filename }} != ""
run: |
echo "${{ steps.zip_artifact_file.filename }}"
echo "${{ steps.zip_artifact_file.basename }}"
- name: Check epub file (DEBUG)
if: ${{ steps.epub_artifact_file.filename }} != ""
run: |
echo "${{ steps.epub_artifact_file.filename }}"
echo "${{ steps.epub_artifact_file.basename }}"
test "v${{ steps.get_version.outputs.VERSION }}" == "${{ env.TAG_NAME }}"
- name: Get Release Notes
run: git tag -l --format='%(contents:body)' v${{ steps.get_version.outputs.VERSION }} | tee .RELEASE_NOTES.md

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME}}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
body_path: .RELEASE_NOTES.md
draft: false
prerelease: false

- name: Upload html (zip) asset
id: upload-release-asset-zip
if: ${{ steps.zip_artifact_file.filename }} != ""
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.zip_artifact_file.filename }}
asset_name: ${{ steps.zip_artifact_file.basename }}
asset_content_type: application/zip

- name: Add html asset to _downloads file
if: ${{ steps.zip_artifact_file.filename }} != ""
run: echo "[html]: ${{ steps.upload-release-asset-zip.outputs.browser_download_url}}" >> _downloads

- name: Upload pdf asset
id: upload-release-asset-pdf
if: ${{ steps.pdf_artifact_file.filename }} != ""
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.pdf_artifact_file.filename }}
asset_name: ${{ steps.pdf_artifact_file.basename }}
asset_content_type: application/pdf

- name: Add pdf asset to _downloads file
if: ${{ steps.pdf_artifact_file.filename }} != ""
run: echo "[pdf]: ${{ steps.upload-release-asset-pdf.outputs.browser_download_url}}" >> _downloads

- name: Upload epub asset
id: upload-release-asset-epub
if: ${{ steps.epub_artifact_file.filename }} != ""
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.epub_artifact_file.filename }}
asset_name: ${{ steps.epub_artifact_file.basename }}
asset_content_type: application/epub+zip

- name: Add epub asset to _downloads file
if: ${{ steps.epub_artifact_file.filename }} != ""
run: echo "[epub]: ${{ steps.upload-release-asset-epub.outputs.browser_download_url}}" >> _downloads

- uses: actions/upload-artifact@v2
name: Create _downloads artifact
with:
name: _downloads
path: |
_downloads
deploy_gh_pages:
name: Deploy documentation to gh-pages
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
if: always() && needs.build_docs.result == 'success' && (github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-18.04
needs: build_docs
needs: [build_docs, create_github_release]
steps:

- uses: actions/setup-python@v2
Expand Down

0 comments on commit 9bde4ee

Please sign in to comment.