|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - preview |
| 7 | + - release |
| 8 | + |
| 9 | +jobs: |
| 10 | + compile_pdf: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v1 |
| 14 | + - name: "install dependencies" |
| 15 | + run: | |
| 16 | + set -ex |
| 17 | + sudo apt -q update |
| 18 | + sudo apt install -y texlive-latex-base texlive-latex-extra latexmk |
| 19 | + - name: "Compile PDF" |
| 20 | + run: | |
| 21 | + set -ex |
| 22 | + cd spec |
| 23 | + latexmk -pdflatex terminal-unicode-core |
| 24 | + - name: "Uploading PDF" |
| 25 | + uses: actions/upload-artifact@v2 |
| 26 | + with: |
| 27 | + name: spec |
| 28 | + path: spec/terminal-unicode-core.pdf |
| 29 | + if-no-files-found: error |
| 30 | + |
| 31 | + compile_md: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v1 |
| 35 | + - name: "install dependencies" |
| 36 | + run: | |
| 37 | + set -ex |
| 38 | + sudo apt -q update |
| 39 | + sudo apt install -y pandoc |
| 40 | + - name: "Compile markdown" |
| 41 | + run: | |
| 42 | + set -ex |
| 43 | + cd spec |
| 44 | + pandoc -s terminal-unicode-core.tex -o terminal-unicode-core.md |
| 45 | + - name: "Uploading markdown" |
| 46 | + uses: actions/upload-artifact@v2 |
| 47 | + with: |
| 48 | + name: spec |
| 49 | + path: spec/terminal-unicode-core.md |
| 50 | + if-no-files-found: error |
| 51 | + |
| 52 | + do_release: |
| 53 | + name: Create Github release |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: [compile_pdf, compile_md] |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v1 |
| 58 | + # ------------------------------------------------------------- |
| 59 | + - name: fetch release artifacts |
| 60 | + uses: actions/download-artifact@v2 |
| 61 | + with: |
| 62 | + name: spec |
| 63 | + # ------------------------------------------------------------- |
| 64 | + - name: Set Output Variables |
| 65 | + id: set_env_var |
| 66 | + env: |
| 67 | + REPOSITORY: ${{ github.event.repository.name }} |
| 68 | + run: | |
| 69 | + VERSION=$(grep '^### ' Changelog.md | head -n1 | awk '{print $2}') |
| 70 | + SUFFIX=$(grep '^### ' Changelog.md | head -n1 | awk '{print $3}' | tr -d '()') |
| 71 | + if [ $REPOSITORY = "master" ]; then IS_PRE='false'; else IS_PRE='true'; fi |
| 72 | + if [ $REPOSITORY = "master" ]; then SUFFIX='' ; else SUFFIX='prerelease'; fi |
| 73 | + if [ $REPOSITORY != "master" ]; then |
| 74 | + TAG_SUFFIX="_prerelease_${GITHUB_RUN_NUMBER}" |
| 75 | + else |
| 76 | + TAG_SUFFIX="" |
| 77 | + fi |
| 78 | + RELEASEBODY=$(awk -v RS='^### ' '/^'$VERSION'/ {print $0}' Changelog.md | tail -n+3) |
| 79 | + RELEASEBODY="${RELEASEBODY//'%'/'%25'}" |
| 80 | + RELEASEBODY="${RELEASEBODY//$'\n'/'%0A'}" |
| 81 | + RELEASEBODY="${RELEASEBODY//$'\r'/'%0D'}" |
| 82 | + echo "::set-output name=version::${VERSION}" |
| 83 | + echo "::set-output name=tag_suffix::${TAG_SUFFIX}" |
| 84 | + echo "::set-output name=RUN_ID::${GITHUB_RUN_NUMBER}" |
| 85 | + echo "::set-output name=IS_PRERELEASE::${IS_PRE}" |
| 86 | + echo "::set-output name=RELEASENAME_SUFFIX::${SUFFIX}" |
| 87 | + echo "::set-output name=RELEASEBODY::${RELEASEBODY}" |
| 88 | + # ------------------------------------------------------------- |
| 89 | + - name: Create Github release page |
| 90 | + id: create_release |
| 91 | + uses: actions/create-release@v1 |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + with: |
| 95 | + tag_name: v${{ steps.set_env_var.outputs.version }}${{ steps.set_env_var.outputs.tag_suffix}} |
| 96 | + release_name: Terminal Good Image Protocol ${{ steps.set_env_var.outputs.version }}-${{ steps.set_env_var.outputs.RUN_ID }} ${{ steps.set_env_var.outputs.RELEASENAME_SUFFIX}} |
| 97 | + body: | |
| 98 | + ${{ steps.set_env_var.outputs.RELEASEBODY }} |
| 99 | + draft: true |
| 100 | + prerelease: ${{ steps.set_env_var.outputs.IS_PRERELEASE }} |
| 101 | + # ------------------------------------------------------------- |
| 102 | + - name: Upload PDF |
| 103 | + id: upload-release-pdf |
| 104 | + uses: actions/upload-release-asset@v1 |
| 105 | + env: |
| 106 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + with: |
| 108 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 109 | + asset_path: terminal-unicode-core.pdf |
| 110 | + asset_name: terminal-unicode-core-${{ steps.set_env_var.outputs.version }}-${{ steps.set_env_var.outputs.RUN_ID }}.pdf |
| 111 | + asset_content_type: application/pdf |
| 112 | + # ------------------------------------------------------------- |
| 113 | + - name: Upload markdown |
| 114 | + id: upload-release-md |
| 115 | + uses: actions/upload-release-asset@v1 |
| 116 | + env: |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + with: |
| 119 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 120 | + asset_path: terminal-unicode-core.md |
| 121 | + asset_name: terminal-unicode-core-${{ steps.set_env_var.outputs.version }}-${{ steps.set_env_var.outputs.RUN_ID }}.md |
| 122 | + asset_content_type: text/markdown |
| 123 | + |
0 commit comments