Skip to content

Commit e0fd08f

Browse files
committed
Improve and correct stack upload documentation
1 parent e93445f commit e0fd08f

File tree

2 files changed

+134
-46
lines changed

2 files changed

+134
-46
lines changed

doc/GUIDE_advanced.md

Lines changed: 112 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,36 @@ ghc-9.0.2
250250
Hackage only accepts packages for uploading in a standard form, a compressed
251251
archive ('tarball') in the format produced by Cabal's `sdist` action.
252252

253-
`stack sdist` generates an file for your package, in the format accepted by
253+
`stack sdist` generates a file for your package, in the format accepted by
254254
Hackage for uploads. The command will report the location of the generated file.
255-
The location can be changed from the default using the
256-
`--tar-dir <path_to_directory>` option.
257255

258-
By default, the command will check the package for common mistakes. This can be
259-
disabled with the flag `--ignore-check`.
256+
### The `stack sdist --ignore-check` flag
260257

261-
Setting the flag `--test-tarball` will cause Stack to attempt to build the
262-
resulting package archive, to test it.
258+
Pass the flag to disable checks of the package for common mistakes. By default,
259+
the command will check the package for common mistakes.
260+
261+
### The `stack sdist --pvp-bounds` option
262+
263+
The `--pvp-bounds <pvp_bounds_mode>` option determines whether and, if so, how
264+
PVP version bounds should be added to the Cabal file of the package. The
265+
available modes for basic use are: `none`, `lower`, `upper`, and `both`. The
266+
available modes for use with Cabal file revisions are `lower-revision`,
267+
`upper-revision` and `both-revision`.
268+
269+
For futher information, see the
270+
[YAML configuration](yaml_configuration.md#pvp-bounds) documentation.
271+
272+
### The `stack sdist --tar-dir` option
273+
274+
The `--tar-dir <path_to_directory>` option determines whether the package
275+
archive should be copied to the specified directory.
276+
277+
### The `stack sdist --[no-]test-tarball` flag
278+
279+
Default: Disabled
280+
281+
Set the flag to cause Stack to test the resulting package archive, by attempting
282+
to build it.
263283

264284
## The `stack templates` command
265285

@@ -350,43 +370,99 @@ accepts an optional `--to` argument to specify the destination directory.
350370

351371
## The `stack upload` command
352372

353-
`stack upload` uploads an sdist to Hackage. As of version
354-
[1.1.0](https://docs.haskellstack.org/en/v1.1.0/ChangeLog/) Stack will also
355-
attempt to GPG sign your packages as per
356-
[our blog post](https://www.fpcomplete.com/blog/2016/05/stack-security-gnupg-keys).
373+
Hackage accepts packages for uploading in a standard form, a compressed archive
374+
('tarball') in the format produced by Cabal's `sdist` action.
375+
376+
`stack upload` generates a file for your package, in the format accepted by
377+
Hackage for uploads, and uploads the package to Hackage. For example, if the
378+
current working directory is the root directory of your project:
379+
380+
~~~text
381+
stack upload .
382+
~~~
383+
384+
### The `HACKAGE_USERNAME` and `HACKAGE_PASSWORD` environment variables
385+
386+
[:octicons-tag-24: 2.3.1](https://github.com/commercialhaskell/stack/releases/tag/v2.3.1)
387+
388+
`stack upload` will request a Hackage username and password to authenticate.
389+
This can be avoided by setting the `HACKAGE_USERNAME` and `HACKAGE_PASSWORD`
390+
environment variables. For
391+
example:
392+
393+
=== "Unix-like"
357394

358-
* `--no-signature` disables signing of packages
359-
* `--candidate` upload a
360-
[package candidate](http://hackage.haskell.org/upload#candidates)
361-
* Hackage API key can be used instead of username and password. For example, on
362-
Unix-like operating systems command:
395+
~~~text
396+
export $HACKAGE_USERNAME="<username>"
397+
export $HACKAGE_PASSWORD="<password>"
398+
stack upload .
399+
~~~
363400

364-
~~~text
365-
HACKAGE_KEY=<api_key>
366-
stack upload .
367-
~~~
401+
=== "Windows (with PowerShell)"
368402

369-
and on Windows (with PowerShell) command:
403+
~~~text
404+
$Env:HACKAGE_USERNAME='<username>'
405+
$Env:HACKAGE_PASSWORD='<password>'
406+
stack upload .
407+
~~~
370408

371-
~~~text
372-
$Env:HACKAGE_KEY=<api_key>
373-
stack upload .
374-
~~~
409+
### The `HACKAGE_KEY` environment variable
375410

376-
* `username` and `password` can be read by setting the following environment
377-
variables. On Unix-like operating systems command:
411+
[:octicons-tag-24: 2.7.5](https://github.com/commercialhaskell/stack/releases/tag/v2.7.5)
378412

379-
~~~text
380-
export $HACKAGE_USERNAME="<username>"
381-
export $HACKAGE_PASSWORD="<password>"
382-
~~~
413+
Hackage allows its members to register an API authentification token and to
414+
authenticate using the token.
383415

384-
and on Windows (with PowerShell) command:
416+
A Hackage API authentification token can be used with `stack upload` instead of
417+
username and password, by setting the `HACKAGE_KEY` environment variable. For
418+
example:
419+
420+
=== "Unix-like"
421+
422+
~~~text
423+
HACKAGE_KEY=<api_authentification_token>
424+
stack upload .
425+
~~~
426+
427+
=== "Windows (with PowerShell)"
428+
429+
~~~text
430+
$Env:HACKAGE_KEY=<api_authentification_token>
431+
stack upload .
432+
~~~
433+
434+
### The `stack upload --candidate` flag
435+
436+
Pass the flag to upload a
437+
[package candidate](http://hackage.haskell.org/upload#candidates).
438+
439+
### The `stack upload --ignore-check` flag
440+
441+
Pass the flag to disable checks of the package for common mistakes. By default,
442+
the command will check the package for common mistakes.
443+
444+
### The `stack upload --pvp-bounds` option
445+
446+
The `--pvp-bounds <pvp_bounds_mode>` option determines whether and, if so, how
447+
PVP version bounds should be added to the Cabal file of the package. The
448+
available modes for basic use are: `none`, `lower`, `upper`, and `both`. The
449+
available modes for use with Cabal file revisions are `lower-revision`,
450+
`upper-revision` and `both-revision`.
451+
452+
For futher information, see the
453+
[YAML configuration](yaml_configuration.md#pvp-bounds) documentation.
454+
455+
### The `stack upload --tar-dir` option
456+
457+
The `--tar-dir <path_to_directory>` option determines whether the package
458+
archive should be copied to the specified directory.
459+
460+
### The `stack upload --[no-]test-tarball` flag
461+
462+
Default: Disabled
385463

386-
~~~text
387-
$Env:HACKAGE_USERNAME='<username>'
388-
$Env:HACKAGE_PASSWORD='<password>'
389-
~~~
464+
Set the flag to cause Stack to test the resulting package archive, by attempting
465+
to build it.
390466

391467
## Docker integration
392468

doc/yaml_configuration.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,11 @@ default. For more information on this change, see
975975

976976
[:octicons-tag-24: 0.1.5.0](https://github.com/commercialhaskell/stack/releases/tag/v0.1.5.0)
977977

978+
Default: `none`
979+
980+
Command line equivalent (takes precedence): `stack sdist --pvp-bounds` option or
981+
`stack upload --pvp-bounds` option
982+
978983
!!! warning
979984

980985
As of Stack 1.6.0, this feature does not reliably work, due to issues with
@@ -985,7 +990,11 @@ default. For more information on this change, see
985990

986991
When using the `sdist` and `upload` commands, this setting determines whether
987992
the Cabal file's dependencies should be modified to reflect PVP lower and upper
988-
bounds. Values are `none` (unchanged), `upper` (add upper bounds), `lower` (add
993+
bounds.
994+
995+
#### Basic use
996+
997+
Values are `none` (unchanged), `upper` (add upper bounds), `lower` (add
989998
lower bounds), and both (and upper and lower bounds). The algorithm it follows
990999
is:
9911000

@@ -1002,16 +1011,19 @@ pvp-bounds: none
10021011
For further information, see the announcement
10031012
[blog post](https://www.fpcomplete.com/blog/2015/09/stack-pvp).
10041013

1005-
!!! note
1014+
#### Use with Cabal file revisions
1015+
1016+
[:octicons-tag-24: 1.5.0](https://github.com/commercialhaskell/stack/releases/tag/v1.5.0)
1017+
1018+
Each of the values listed above supports adding `-revision` to the end of the
1019+
value, e.g. `pvp-bounds: both-revision`. This means that, when uploading to
1020+
Hackage, Stack will first upload your tarball with an unmodified Cabal file, and
1021+
then upload a Cabal file revision with the PVP bounds added.
10061022

1007-
Since Stack 1.5.0, each of the values listed above supports adding
1008-
`-revision` to the end of each value, e.g. `pvp-bounds: both-revision`. This
1009-
means that, when uploading to Hackage, Stack will first upload your tarball
1010-
with an unmodified Cabal file, and then upload a Cabal file revision with
1011-
the PVP bounds added. This can be useful - especially combined with the
1012-
[Stackage no-revisions feature](http://www.snoyman.com/blog/2017/04/stackages-no-revisions-field) -
1013-
as a method to ensure PVP compliance without having to proactively fix
1014-
bounds issues for Stackage maintenance.
1023+
This can be useful - especially combined with the
1024+
[Stackage no-revisions feature](http://www.snoyman.com/blog/2017/04/stackages-no-revisions-field) -
1025+
as a method to ensure PVP compliance without having to proactively fix bounds
1026+
issues for Stackage maintenance.
10151027

10161028
### recommend-stack-upgrade
10171029

0 commit comments

Comments
 (0)