ci: Swap candidate/final release logic

During the release of xmonad 0.17.0, I realized that we need to be able
to upload candidates before tagging the release on GitHub, because there
might be issues with the tarball and Hackage may reject it. When that
happened, I had to remove the release, delete the tag, upload the
candidate manually to see what's wrong with it, try to fix it, upload it
manually again, and so on.

This commit swaps the logic: when the workflow is invoked manually, it
uploads the candidate. This can be done multiple times, and once
everything is fine, the release can finally be tagged and it's released
to Hackage proper. The only disadvantage is that we need to remember to
try uploading the candidate. Not sure if there's a perfect solution…
This commit is contained in:
Tomas Janousek 2021-10-29 19:07:38 +01:00
parent 99e1b30e86
commit b40b672288
2 changed files with 26 additions and 28 deletions

View File

@ -2,14 +2,16 @@ Piggy-back on the haskell-ci workflow for automatic releases to Hackage.
This extends the workflow with two additional triggers: This extends the workflow with two additional triggers:
* When a release is created on GitHub, a candidate release is uploaded to * When the Haskell-CI workflow is triggered manually with a non-empty version
Hackage and docs are submitted for it as Hackage can't build them itself input (matching the version in the cabal file), a candidate release is
(https://github.com/haskell/hackage-server/issues/925). uploaded to Hackage and docs are submitted for it as Hackage can't build
them itself (https://github.com/haskell/hackage-server/issues/925).
* To make a final release, the workflow can be triggered manually by entering Note that promoting the candidate on Hackage discards the uploaded docs
the correct version number matching the version in the cabal file. This is (https://github.com/haskell/hackage-server/issues/70). Don't do that.
here because promoting the candidate on Hackage discards the uploaded docs
(https://github.com/haskell/hackage-server/issues/70). * When a release is created on GitHub, a final release is uploaded to Hackage
and docs are submitted for it.
The automation uses a special Hackage user: https://hackage.haskell.org/user/xmonad The automation uses a special Hackage user: https://hackage.haskell.org/user/xmonad
and each repo (X11, xmonad, xmonad-contrib) has its own HACKAGE_API_KEY token and each repo (X11, xmonad, xmonad-contrib) has its own HACKAGE_API_KEY token
@ -17,7 +19,7 @@ set in GitHub repository secrets.
--- .github/workflows/haskell-ci.yml.orig --- .github/workflows/haskell-ci.yml.orig
+++ .github/workflows/haskell-ci.yml +++ .github/workflows/haskell-ci.yml
@@ -14,8 +14,17 @@ @@ -14,8 +14,15 @@
# #
name: Haskell-CI name: Haskell-CI
on: on:
@ -31,21 +33,19 @@ set in GitHub repository secrets.
+ workflow_dispatch: + workflow_dispatch:
+ inputs: + inputs:
+ version: + version:
+ # releases to Hackage are final and cannot be reverted, thus require + description: candidate version (must match version in cabal file)
+ # manual entry of version as a poor man's mistake avoidance
+ description: version (must match version in cabal file)
jobs: jobs:
linux: linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }} name: Haskell-CI - Linux - ${{ matrix.compiler }}
@@ -28,6 +37,7 @@ @@ -31,6 +38,7 @@
include: compilerVersion: 9.0.1
- compiler: ghc-9.0.1 setup-method: hvr-ppa
allow-failure: false allow-failure: false
+ upload: true + upload: true
- compiler: ghc-8.10.4 - compiler: ghc-8.10.4
allow-failure: false compilerKind: ghc
- compiler: ghc-8.8.4 compilerVersion: 8.10.4
@@ -171,8 +181,66 @@ @@ -209,8 +217,66 @@
${CABAL} -vnormal check ${CABAL} -vnormal check
- name: haddock - name: haddock
run: | run: |
@ -66,7 +66,7 @@ set in GitHub repository secrets.
+ with: + with:
+ 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 == 'release' + if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
+ run: | + run: |
+ set -ex + set -ex
+ PACKAGE_VERSION="${PACKAGE_VERSION#v}" + PACKAGE_VERSION="${PACKAGE_VERSION#v}"
@ -88,9 +88,9 @@ set in GitHub repository secrets.
+ 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.release.tag_name }} + PACKAGE_VERSION: ${{ github.event.inputs.version }}
+ - name: hackage upload (release) + - name: hackage upload (release)
+ if: matrix.upload && github.event_name == 'workflow_dispatch' + if: matrix.upload && github.event_name == 'release'
+ run: | + run: |
+ set -ex + set -ex
+ PACKAGE_VERSION="${PACKAGE_VERSION#v}" + PACKAGE_VERSION="${PACKAGE_VERSION#v}"
@ -112,4 +112,4 @@ set in GitHub repository secrets.
+ 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.release.tag_name }}

View File

@ -22,9 +22,7 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:
# releases to Hackage are final and cannot be reverted, thus require description: candidate version (must match version in cabal file)
# manual entry of version as a poor man's mistake avoidance
description: version (must match version in cabal file)
jobs: jobs:
linux: linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }} name: Haskell-CI - Linux - ${{ matrix.compiler }}
@ -266,7 +264,7 @@ jobs:
with: with:
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 == 'release' if: matrix.upload && github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
run: | run: |
set -ex set -ex
PACKAGE_VERSION="${PACKAGE_VERSION#v}" PACKAGE_VERSION="${PACKAGE_VERSION#v}"
@ -288,9 +286,9 @@ jobs:
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.release.tag_name }} PACKAGE_VERSION: ${{ github.event.inputs.version }}
- name: hackage upload (release) - name: hackage upload (release)
if: matrix.upload && github.event_name == 'workflow_dispatch' if: matrix.upload && github.event_name == 'release'
run: | run: |
set -ex set -ex
PACKAGE_VERSION="${PACKAGE_VERSION#v}" PACKAGE_VERSION="${PACKAGE_VERSION#v}"
@ -312,4 +310,4 @@ jobs:
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.release.tag_name }}