Skip to content

Commit 774eb72

Browse files
authored
Automate signing and uploading stack bindists to Github release (#5409)
Adds to Github Actions workflow, and removes from `release.hs`.
1 parent dfbaa0b commit 774eb72

File tree

3 files changed

+106
-257
lines changed

3 files changed

+106
-257
lines changed

.github/workflows/integration-tests.yml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- master
88
- stable
99
- rc/**
10+
tags:
11+
- '**'
1012
schedule:
1113
- cron: "0 0 * * *"
1214
workflow_dispatch:
@@ -69,7 +71,101 @@ jobs:
6971
name: Build bindist
7072
run: stack etc/scripts/release.hs build ${{ matrix.release-args }}
7173

72-
- uses: actions/upload-artifact@v2
74+
- name: Upload bindist
75+
uses: actions/upload-artifact@v2
7376
with:
7477
name: ${{ runner.os }}
7578
path: _release/stack-*
79+
80+
github-release:
81+
name: Create Github release
82+
needs: integration-tests
83+
runs-on: ubuntu-latest
84+
if: startsWith(github.ref, 'refs/tags/')
85+
steps:
86+
- name: Download Linux artifact
87+
uses: actions/download-artifact@v2
88+
with:
89+
name: Linux
90+
path: _release
91+
- name: Download macOS artifact
92+
uses: actions/download-artifact@v2
93+
with:
94+
name: macOS
95+
path: _release
96+
- name: Download Windows artifact
97+
uses: actions/download-artifact@v2
98+
with:
99+
name: Windows
100+
path: _release
101+
- shell: bash
102+
name: Hash and sign assets
103+
env:
104+
RELEASE_SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }}
105+
run: |
106+
set -e
107+
echo "$RELEASE_SIGNING_KEY"|gpg --import
108+
cd _release
109+
for asset in *; do
110+
shasum -a 256 "$asset" >"$asset.sha256"
111+
gpg --digest-algo=sha512 --detach-sig --armor -u 0x575159689BEFB442 "$asset"
112+
done
113+
- name: Set Github ref variables
114+
id: github_ref_vars
115+
run: |
116+
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
117+
- name: Create Github release (final)
118+
if: "!startsWith(github.ref, 'refs/tags/rc/')"
119+
uses: actions/create-release@v1
120+
env:
121+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+
with:
123+
tag_name: ${{ github.ref }}
124+
body: |
125+
See https://haskellstack.org/ for installation and upgrade instructions.
126+
127+
**Changes since v[INSERT PREVIOUS VERSION]:**
128+
129+
[INSERT CHANGELOG]
130+
131+
**Thanks to all our contributors for this release:**
132+
133+
[INSERT CONTRIBUTORS]
134+
draft: true
135+
prerelease: false
136+
- name: Create Github release (release candidate)
137+
if: "startsWith(github.ref, 'refs/tags/rc/')"
138+
uses: actions/create-release@v1
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
with:
142+
tag_name: ${{ github.ref }}
143+
body: |
144+
[APPEND ` (release candidate)` TO RELEASE NAME]
145+
**Changes since v[INSERT PREVIOUS VERSION]:**
146+
147+
[INSERT CHANGELOG]
148+
draft: true
149+
prerelease: true
150+
- name: Upload assets to Github release (final)
151+
if: "!startsWith(github.ref, 'refs/tags/rc/')"
152+
uses: xresloader/upload-to-github-release@v1
153+
env:
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
with:
156+
file: "_release/*"
157+
tag_name: ${{ steps.github_ref_vars.outputs.SOURCE_TAG }}
158+
draft: true
159+
prerelease: false
160+
overwrite: true
161+
- name: Upload assets to Github release (release candidate)
162+
if: "startsWith(github.ref, 'refs/tags/rc/')"
163+
uses: xresloader/upload-to-github-release@v1
164+
env:
165+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166+
with:
167+
file: "_release/*"
168+
tag_name: ${{ steps.github_ref_vars.outputs.SOURCE_TAG }}
169+
draft: true
170+
prerelease: true
171+
overwrite: true

etc/scripts/README.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ release.hs
33

44
This tool automates some aspects of releasing a new version of Stack. It
55
currently handles some tasks that need to be performed on each platform:
6-
building the release, running some pre-release checks, and uploading binaries to
7-
a Github release.
6+
building the release, running integration tests, and other pre-release checks.
87

98
See [Checklist](../../doc/maintainers/releases.md) of
109
additional manual release steps.
@@ -17,23 +16,6 @@ These must be installed in the PATH to use the release tool:
1716
- stack
1817
- git (for Windows, [msysgit](https://msysgit.github.io) is recommended).
1918

20-
To create a signed binary package, you need:
21-
22-
- GPG installed and in the PATH (included with
23-
[msysgit](https://msysgit.github.io) on Windows)
24-
- `[email protected]` secret key in GPG keyring. You may also use the
25-
environment variable `STACK_RELEASE_GPG_KEY`, which should be
26-
set to the hexadecimal (0xLONG) identifier of the GPG key.
27-
28-
To upload a binary to a Github release, you also need:
29-
30-
- A [Github authorization token](https://github.com/settings/tokens) with
31-
`public_repo` scope.
32-
- Set `GITHUB_AUTH_TOKEN` environment variable to the authorization token.
33-
- A [Github release](https://github.com/commercialhaskell/stack/releases)
34-
(probably as a draft) with a tag for the stack package's version (e.g.
35-
`vX.Y.Z`).
36-
3719
Invocation
3820
----------
3921

@@ -46,28 +28,13 @@ The tool must be run in the root of the working tree.
4628
The release tool is shake-based, so all standard shake options apply. In
4729
addition, the following options are accepted:
4830

49-
* `--gpg-key`: override GPG key used to sign the distribution packages. By
50-
default the `[email protected]` key is used.
51-
* `--github-auth-token`: override the Github authorization token.
52-
* `--github-release-tag`: overrides the Github Release tag that binaries are
5331
* `--allow-dirty`: by default, the `check` rule aborts if the working tree is
5432
dirty, but this will allow it to continue.
5533
uploaded to.
5634

57-
You may also use the following environment variables in order to use a custom
58-
GPG key:
59-
* `STACK_RELEASE_GPG_KEY` should be set to the hexadecimal identifier (0xLONG) of the
60-
GPG key
61-
6235
### Targets
6336

64-
* `release`: check, build, and upload.
37+
* `release`: check and build.
6538
* `check`: run pre-release checks.
6639
* `build`: build and sign the binary distribution.
67-
* `upload`: upload the binary distribution to the Github release.
68-
* `build-<distro>-<ver>`: build package for Linux distribution.
69-
* `upload-<distro>-<ver>`: upload package for Linux distribution to private package repository.
7040
* `clean`: delete the build artifacts.
71-
72-
`<distro>` can have one of these values: `ubuntu`, `debian`, `centos`, `fedora`.
73-
`<ver>` is the version of the distribution (e.g., `14.04` for Ubuntu).

0 commit comments

Comments
 (0)