Skip to content

Commit

Permalink
Merge pull request #13 from fourmolu/bump-to-fourmolu-0.10.1.0
Browse files Browse the repository at this point in the history
Bump to fourmolu-0.10.1.0
  • Loading branch information
wraithm authored Dec 5, 2022
2 parents e99dcf3 + 2a1ed0a commit 0a81af8
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Fourmolu action v6

* Uses Fourmolu 0.10.1.0

## Fourmolu action v5

* Uses Fourmolu 0.9.0.0.
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ versions available. Each version of the Fourmolu Action generally has a
corresponding version of `fourmolu`. Make sure you pick a Fourmolu Action
version that uses the version of `fourmolu` you use locally.

### Full Example
### Full example

Here's a full YAML file you can copy and paste into your repo that runs
`fourmolu-action`. Add this as a file like `.github/workflows/fourmolu.yaml`.
Expand Down Expand Up @@ -59,7 +59,7 @@ Here's a more complicated example that shows more options being used:
extra-args: "--indent-wheres true"
```

### Example Usage with Build Matrix
### Example usage with build matrix

If you are using a build matrix, then it is more efficient to have a
separate job for checking of formatting:
Expand Down Expand Up @@ -136,6 +136,22 @@ 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: [`./bump.sh`](./bump.sh).
This can be run to bump the version of `fourmolu` used by `fourmolu-action`,
and create a PR for this version bump.

After this PR has been reviewed and merged in, you can create the Release on
GitHub with the following commands. Make sure you're on the `master` branch:

```console
$ gh release create --notes "This release uses fourmolu-0.9.0.0." --title "v4" v4
```

You can then run `git fetch` to fetch the new tag that has been automatically
created.

### Making a new release manually

The following steps describe how to make a new release of `fourmolu-action`.
Before making a new release, make sure you've correctly bumped the version
of `fourmolu` used in `index.js` to match the most recent version
Expand Down
68 changes: 68 additions & 0 deletions bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
#
# A simple shell script for bumping the version of fourmolu-action to use the
# latest GitHub release of Fourmolu. This script also creates a PR for this
# version bump.

set -euo pipefail

# find current version of fourmolu used in fourmolu-action.
fourmolu_old_version=$(sed -En "s/^const fourmolu_version = '(.*?)';$/\1/p" "./index.js")

# This is the latest release version of spago on GitHub.
fourmolu_new_version=$(curl --silent "https://api.github.com/repos/fourmolu/fourmolu/releases" | jq '.[0].tag_name' --raw-output)

# Fourmolu has tags like "v0.10.1.0", so we need to drop the first 'v'
# character.
fourmolu_new_version="${fourmolu_new_version:1}"

echo "Updating fourmolu-action from fourmolu-${fourmolu_old_version} to fourmolu-${fourmolu_new_version} ..."

# Update the version in ./index.js
sed -i -e "s/^const fourmolu_version = '.*';/const fourmolu_version = '${fourmolu_new_version}';/" "./index.js"

# Regenerate the dist/index.js file
npm run prepare

# Find the most recent fourmolu-action release number
fourmolu_action_old_version="$(gh release list | head -n1 | cut -f1)"
fourmolu_action_old_version="${fourmolu_action_old_version:1}"

fourmolu_action_new_version=$((fourmolu_action_old_version + 1))

echo "Current fourmolu-action version: v${fourmolu_action_old_version}. Next fourmolu-action version: v${fourmolu_action_new_version}."

echo "Updating CHANGELOG.md with info about new release..."

cat << EOF > ./new-changelog-entry
## Fourmolu action v${fourmolu_action_new_version}
* Uses Fourmolu ${fourmolu_new_version}
EOF

cat ./new-changelog-entry ./CHANGELOG.md > ./new-changelog
mv ./new-changelog ./CHANGELOG.md
rm ./new-changelog-entry

new_git_branch="bump-to-fourmolu-${fourmolu_new_version}"

echo "Create new git branch named '${new_git_branch}'..."

git checkout -b "$new_git_branch"

echo "Doing git add on ./CHANGELOG.md ./index.js ./dist/index.js..."

git add ./CHANGELOG.md ./index.js ./dist/index.js

echo "Creating git commit..."

git commit -m "Bumping to fourmolu-${fourmolu_new_version}"

echo "Pushing branch to github..."

git push origin HEAD

echo "Opening PR on GitHub..."

gh pr create --title "Bump to fourmolu-${fourmolu_new_version}" --body "https://github.com/fourmolu/fourmolu/releases/tag/v${fourmolu_new_version}"
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const tool_cache = __webpack_require__(7784);
const exec = __webpack_require__(1514);
const glob = __webpack_require__(8090);

const fourmolu_version = '0.9.0.0';
const fourmolu_version = '0.10.1.0';

// XXX: These release binaries appear to be dynamically linked, so they may not
// run on some systems.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const tool_cache = require('@actions/tool-cache');
const exec = require('@actions/exec');
const glob = require('@actions/glob');

const fourmolu_version = '0.9.0.0';
const fourmolu_version = '0.10.1.0';

// XXX: These release binaries appear to be dynamically linked, so they may not
// run on some systems.
Expand Down

0 comments on commit 0a81af8

Please sign in to comment.