From c83d8f5566b18fb4c356bb2941b1916be58d0613 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Sun, 9 Jun 2024 23:29:18 +0200 Subject: [PATCH] fix: handle both prior 1.10 and 1.10+ metanorma actions-mn/build-and-publish#15 --- .github/workflows/test.yml | 48 +++++++++++++++++++++++++++-- action.yml | 63 +++++++++++++++++++++++++++++++------- 2 files changed, 98 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16f039a..c6b7562 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: - run: | sudo apt-get install yamllint yamllint action.yml + test-site-gen: name: Test ./site-gen/ action on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -27,9 +28,9 @@ jobs: matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: metanorma/mn-samples-iso path: iso @@ -45,3 +46,46 @@ jobs: - uses: andstor/file-existence-action@v1 with: files: iso/_site/index.html + + test-before-1-10: + runs-on: ubuntu-latest + container: + image: metanorma/metanorma:1.9.7 + steps: + - uses: actions/checkout@v4 + + - uses: actions/checkout@v4 + with: + repository: metanorma/mn-samples-cc + path: cc + + - uses: ./ + with: + token: ${{ secrets.GITHUB_TOKEN }} + source-path: cc + agree-to-terms: true + + - uses: andstor/file-existence-action@v1 + with: + files: cc/_site/index.html + + test-1-10: + runs-on: ubuntu-latest + container: + image: metanorma/metanorma:1.10.0 + steps: + - uses: actions/checkout@v4 + + - uses: actions/checkout@v4 + with: + repository: metanorma/mn-samples-cc + path: cc + + - uses: ./ + with: + source-path: cc + agree-to-terms: true + + - uses: andstor/file-existence-action@v1 + with: + files: cc/_site/index.html \ No newline at end of file diff --git a/action.yml b/action.yml index 572c627..7f1d1a9 100644 --- a/action.yml +++ b/action.yml @@ -24,6 +24,9 @@ inputs: strict: description: 'Run metanorma in strict mode' default: '' # false + progress: + description: 'Display progress related logs' + default: 'false' # false use-bundler: description: 'Run in bundler' default: '' # false @@ -35,14 +38,52 @@ inputs: runs: using: "composite" steps: - - shell: bash - run: | - cd ${{ inputs.source-path }} - ${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \ - metanorma site generate . \ - ${{ inputs.strict && '--strict' || '' }} \ - -o ${{ inputs.output-dir }} \ - -c ${{ inputs.config-file }} \ - ${{ inputs.agree-to-terms && '--' || '--no-' }}agree-to-terms \ - ${{ inputs.install-fonts && '--' || '--no-' }}install-fonts \ - ${{ inputs.continue-without-fonts && '--' || '--no-' }}continue-without-fonts + - shell: bash + run: | + verlte() { + printf '%s\n' "$1" "$2" | sort -C -V + } + verlt() { + ! verlte "$2" "$1" + } + + METANORMA_VERSION=$(${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} metanorma --version | head -1 | cut -d' ' -f2) + verlt ${METANORMA_VERSION} 1.10.0 + METANORMA_LEGACY=$? + METANORMA_FLAGS="" + + if [ "${{ inputs.strict }}" == "true" ]; then + METANORMA_FLAGS+="--strict" + fi + if [ "${{ inputs.progress }}" != "true" ]; then + METANORMA_FLAGS+=" --no-progress" + fi + if [ "${{ inputs.agree-to-terms }}" == "true" ]; then + METANORMA_FLAGS+=" --agree-to-terms" + fi + + if [ "${{ inputs.install-fonts }}" != 'true' ]; then + METANORMA_FLAGS+=" --no-install-fonts" + elif [ $METANORMA_LEGACY -eq 0 ]; then + METANORMA_FLAGS+=" --no-no-install-fonts" + else + METANORMA_FLAGS+=" --install-fonts" + fi + + if [ "${{ inputs.continue-without-fonts }}" != 'true' ]; then + METANORMA_FLAGS+=" --no-continue-without-fonts" + elif [ $METANORMA_LEGACY -eq 0 ]; then + METANORMA_FLAGS+=" --no-no-continue-without-fonts" + else + METANORMA_FLAGS+=" --continue-without-fonts" + fi + echo "METANORMA_FLAGS=${METANORMA_FLAGS}" >> $GITHUB_ENV + + - shell: bash + run: | + cd ${{ inputs.source-path }} + ${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \ + metanorma site generate . \ + -o ${{ inputs.output-dir }} \ + -c ${{ inputs.config-file }} \ + ${{ env.METANORMA_FLAGS }} \ No newline at end of file