Skip to content

Commit

Permalink
Merge pull request #21 from haskell-actions/auto-latest-version
Browse files Browse the repository at this point in the history
Automatically figure out the latest version of fourmolu
  • Loading branch information
wraithm authored Jun 12, 2023
2 parents b8c81ae + 157c5ff commit 5f70569
Show file tree
Hide file tree
Showing 12 changed files with 11,709 additions and 13,095 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
## run-fourmolu v9

* `run-fourmolu` Action now takes a `version` argument to allow you to
specify the version of Fourmolu you want to use. If you don't specify the
`version` argument, then the _latest_ version of Fourmolu will be used.
**Note that this is a breaking change for all current users of
`run-fourmolu`**.

With this change, you're now able to use a single version of `run-fourmolu`
with different versions of Fourmolu.

Here's an example of how you'd use `run-fourmolu` with the 0.12.0.0 version
of Fourmolu:

```yaml
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.12.0.0"
```
It is recommended to always specify the version of Fourmolu you want to
use, since Fourmolu is often not backwards compatible. New releases of
Fourmolu could possibly break your CI. However, if you want to always
use the newest release of fourmolu, you can do it like the following:
```yaml
- uses: haskell-actions/run-fourmolu@v9
with:
version: "latest"
```
Alternatively, you can leave out the `version` argument and it will default
to `latest`.

## run-fourmolu v8

* Uses Fourmolu 0.12.0.0
Expand Down
78 changes: 47 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,46 @@
![CI](https://github.com/haskell-actions/run-fourmolu/workflows/CI/badge.svg?branch=master)

This `run-fourmolu` GitHub Action helps to ensure that your Haskell project is
formatted with [Fourmolu][fourmolu]. The action tries to find all Haskell source
code files in your repository and fails if any of them are not formatted. In
case of failure it prints the diff between the actual contents of the file
and its formatted version.
formatted with [Fourmolu][https://github.com/fourmolu/fourmolu/]. The action
tries to find all Haskell source code files in your repository and fails if any
of them are not formatted. In case of failure it prints the diff between the
actual contents of the file and its formatted version.

## Example usage

In the simple case all you need to do is to add this step to your job:

```yaml
- uses: haskell-actions/run-fourmolu@v7
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.13.0.0"
```
The `@v7` after `haskell-actions/run-fourmolu` should be replaced with the version of the
The `0.13.0.0` should be replaced with the version of Fourmolu you want to use. See
[Fourmolu releases](https://github.com/fourmolu/fourmolu/releases) for all Fourmolu versions.
If you don't specify this Fourmolu `version` input, the latest version of
Fourmolu will be used.

The `@v9` after `haskell-actions/run-fourmolu` should be replaced with the version of the
`run-fourmolu` Action you want to use. See
[Releases](https://github.com/haskell-actions/run-fourmolu/releases) for all
versions available. Each version of the `run-fourmolu` Action generally has a
corresponding version of `fourmolu`. Make sure you pick a `run-fourmolu` Action
version that uses the version of `fourmolu` you use locally.
[run-fourmolu releases](https://github.com/haskell-actions/run-fourmolu/releases) for all
run-fourmolu versions available.

## Example using latest version of Fourmolu

You can use the latest version of Fourmolu by specifying `version: "latest"`:
```yaml
- uses: haskell-actions/run-fourmolu@v9
with:
version: "latest"
```
Alternatively, if you leave out the `version` input, then `"latest"` will be assumed.

_It is recommended that users always specify the exact version of Fourmolu they
want to use, since new releases of Fourmolu are often not backwards compatible.
Your CI may break when there is a new release of Fourmolu._

### Full example

Expand All @@ -38,16 +59,22 @@ jobs:
steps:
# Note that you must checkout your code before running haskell-actions/run-fourmolu
- uses: actions/checkout@v2
- uses: haskell-actions/run-fourmolu@v7
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.13.0.0"
```

### Example with more Options

Here's a more complicated example that shows more options being used:

```yaml
- uses: haskell-actions/run-fourmolu@v7
- uses: haskell-actions/run-fourmolu@v9
with:
# Use fourmolu-0.13.0.0. If you don't specify this, then the latest
# release of fourmolu will be used.
version: "0.13.0.0"
# Only check the format of .hs in the src/ directory.
pattern: |
src/**/*.hs
Expand All @@ -70,7 +97,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: haskell-actions/run-fourmolu@v7
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.13.0.0"
build:
runs-on: ubuntu-latest
needs: fourmolu
Expand Down Expand Up @@ -136,22 +165,9 @@ to `./dist` whenever you make a change in `./index.js`.

## Making a new release

There is a script to help with making a new release:

```console
$ ./bump.sh
```

This script bumps the version of `fourmolu` used by `run-fourmolu`,
and creates a PR for this version bump.

After this PR has been reviewed and merged in, you can create the new
[Release](https://github.com/haskell-actions/run-fourmolu/releases) on
GitHub with the following command. Make sure you're on the `master` branch:

```console
$ ./make-github-release.sh
```
Do the following steps to make a new release:

[fourmolu]: https://github.com/fourmolu/fourmolu
[git-core-autocrlf]: https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-coreautocrlf
1. Add entries to [`CHANGELOG.md`](./CHANGELOG.md) for all changes since the
last release.
2. Manually create a GitHub release on
<https://github.com/haskell-actions/run-fourmolu/releases/new>.
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ inputs:
required: false
description: >
Extra arguments to pass to Fourmolu.
version:
required: false
description: >
The version number of Fourmolu to use. Defaults to "latest". Example
version numbers -- `0.13.0.0`, `0.10.1.0`, etc. See
https://github.com/fourmolu/fourmolu/releases for a list of all releases.
Note that formatting changes in later versions of Fourmolu are not
necessarily backwards-compatible. You are recommended to specify the
version of fourmolu you wish to use.
default: latest
runs:
using: 'node16'
main: 'dist/index.js'
68 changes: 0 additions & 68 deletions bump.sh

This file was deleted.

Loading

0 comments on commit 5f70569

Please sign in to comment.