ci: Show error body from Hackage when it fails

Prevents having to upload the candidate manually to see what's wrong.
This commit is contained in:
Tomas Janousek
2021-10-29 20:46:20 +01:00
parent 9849800dc5
commit 9f64c2ca90
2 changed files with 89 additions and 61 deletions

View File

@@ -45,7 +45,7 @@ set in GitHub repository secrets.
- compiler: ghc-8.10.4 - compiler: ghc-8.10.4
compilerKind: ghc compilerKind: ghc
compilerVersion: 8.10.4 compilerVersion: 8.10.4
@@ -209,8 +217,66 @@ @@ -209,8 +217,80 @@
${CABAL} -vnormal check ${CABAL} -vnormal check
- name: haddock - name: haddock
run: | run: |
@@ -67,48 +67,62 @@ set in GitHub repository secrets.
+ path: ${{ github.workspace }}/haddock/*-docs.tar.gz + path: ${{ github.workspace }}/haddock/*-docs.tar.gz
+ - name: hackage upload (candidate) + - name: hackage upload (candidate)
+ if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' + if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
+ shell: bash
+ run: | + run: |
+ set -ex + set -ex
+ PACKAGE_VERSION="${PACKAGE_VERSION#v}" + PACKAGE_VERSION="${PACKAGE_VERSION#v}"
+ curl \ + res=$(
+ --silent --show-error --fail \ + curl \
+ --header "Accept: text/plain" \ + --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
+ --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ + --header "Accept: text/plain" \
+ --form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \ + --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
+ https://hackage.haskell.org/packages/candidates/ + --form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \
+ curl \ + https://hackage.haskell.org/packages/candidates/
+ --silent --show-error --fail \ + )
+ -X PUT \ + [[ $res == 2?? ]] # TODO: --fail-with-body once curl 7.76.0 is available
+ --header "Accept: text/plain" \ + res=$(
+ --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ + curl \
+ --header "Content-Type: application/x-tar" \ + --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
+ --header "Content-Encoding: gzip" \ + -X PUT \
+ --data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \ + --header "Accept: text/plain" \
+ https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/candidate/docs + --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
+ --header "Content-Type: application/x-tar" \
+ --header "Content-Encoding: gzip" \
+ --data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \
+ https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/candidate/docs
+ )
+ [[ $res == 2?? ]]
+ env: + env:
+ HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }} + HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }}
+ PACKAGE_NAME: ${{ github.event.repository.name }} + PACKAGE_NAME: ${{ github.event.repository.name }}
+ PACKAGE_VERSION: ${{ github.event.inputs.version }} + PACKAGE_VERSION: ${{ github.event.inputs.version }}
+ - name: hackage upload (release) + - name: hackage upload (release)
+ if: matrix.upload && github.event_name == 'release' + if: matrix.upload && github.event_name == 'release'
+ shell: bash
+ run: | + run: |
+ set -ex + set -ex
+ PACKAGE_VERSION="${PACKAGE_VERSION#v}" + PACKAGE_VERSION="${PACKAGE_VERSION#v}"
+ curl \ + res=$(
+ --silent --show-error --fail \ + curl \
+ --header "Accept: text/plain" \ + --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
+ --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ + --header "Accept: text/plain" \
+ --form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \ + --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
+ https://hackage.haskell.org/packages/ + --form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \
+ curl \ + https://hackage.haskell.org/packages/
+ --silent --show-error --fail \ + )
+ -X PUT \ + [[ $res == 2?? ]] # TODO: --fail-with-body once curl 7.76.0 is available
+ --header "Accept: text/plain" \ + res=$(
+ --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ + curl \
+ --header "Content-Type: application/x-tar" \ + --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
+ --header "Content-Encoding: gzip" \ + -X PUT \
+ --data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \ + --header "Accept: text/plain" \
+ https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/docs + --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
+ --header "Content-Type: application/x-tar" \
+ --header "Content-Encoding: gzip" \
+ --data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \
+ https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/docs
+ )
+ [[ $res == 2?? ]]
+ env: + env:
+ HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }} + HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }}
+ PACKAGE_NAME: ${{ github.event.repository.name }} + PACKAGE_NAME: ${{ github.event.repository.name }}

View File

@@ -245,48 +245,62 @@ jobs:
path: ${{ github.workspace }}/haddock/*-docs.tar.gz path: ${{ github.workspace }}/haddock/*-docs.tar.gz
- name: hackage upload (candidate) - name: hackage upload (candidate)
if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
shell: bash
run: | run: |
set -ex set -ex
PACKAGE_VERSION="${PACKAGE_VERSION#v}" PACKAGE_VERSION="${PACKAGE_VERSION#v}"
curl \ res=$(
--silent --show-error --fail \ curl \
--header "Accept: text/plain" \ --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
--header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ --header "Accept: text/plain" \
--form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \ --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
https://hackage.haskell.org/packages/candidates/ --form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \
curl \ https://hackage.haskell.org/packages/candidates/
--silent --show-error --fail \ )
-X PUT \ [[ $res == 2?? ]] # TODO: --fail-with-body once curl 7.76.0 is available
--header "Accept: text/plain" \ res=$(
--header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ curl \
--header "Content-Type: application/x-tar" \ --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
--header "Content-Encoding: gzip" \ -X PUT \
--data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \ --header "Accept: text/plain" \
https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/candidate/docs --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
--header "Content-Type: application/x-tar" \
--header "Content-Encoding: gzip" \
--data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \
https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/candidate/docs
)
[[ $res == 2?? ]]
env: env:
HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }} HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }}
PACKAGE_NAME: ${{ github.event.repository.name }} PACKAGE_NAME: ${{ github.event.repository.name }}
PACKAGE_VERSION: ${{ github.event.inputs.version }} PACKAGE_VERSION: ${{ github.event.inputs.version }}
- name: hackage upload (release) - name: hackage upload (release)
if: matrix.upload && github.event_name == 'release' if: matrix.upload && github.event_name == 'release'
shell: bash
run: | run: |
set -ex set -ex
PACKAGE_VERSION="${PACKAGE_VERSION#v}" PACKAGE_VERSION="${PACKAGE_VERSION#v}"
curl \ res=$(
--silent --show-error --fail \ curl \
--header "Accept: text/plain" \ --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
--header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ --header "Accept: text/plain" \
--form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \ --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
https://hackage.haskell.org/packages/ --form package=@"${GITHUB_WORKSPACE}/sdist/${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz" \
curl \ https://hackage.haskell.org/packages/
--silent --show-error --fail \ )
-X PUT \ [[ $res == 2?? ]] # TODO: --fail-with-body once curl 7.76.0 is available
--header "Accept: text/plain" \ res=$(
--header "Authorization: X-ApiKey $HACKAGE_API_KEY" \ curl \
--header "Content-Type: application/x-tar" \ --silent --show-error --output /dev/stderr --write-out '%{http_code}' \
--header "Content-Encoding: gzip" \ -X PUT \
--data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \ --header "Accept: text/plain" \
https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/docs --header "Authorization: X-ApiKey $HACKAGE_API_KEY" \
--header "Content-Type: application/x-tar" \
--header "Content-Encoding: gzip" \
--data-binary @"${GITHUB_WORKSPACE}/haddock/${PACKAGE_NAME}-${PACKAGE_VERSION}-docs.tar.gz" \
https://hackage.haskell.org/package/${PACKAGE_NAME}-${PACKAGE_VERSION}/docs
)
[[ $res == 2?? ]]
env: env:
HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }} HACKAGE_API_KEY: ${{ secrets.HACKAGE_API_KEY }}
PACKAGE_NAME: ${{ github.event.repository.name }} PACKAGE_NAME: ${{ github.event.repository.name }}