Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #14 #24

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "CD"
on:
push:
branches:
- "master"
jobs:
changelog:
name: Generate changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate a changelog
uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: --verbose
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- name: Commit
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
set +e
git add CHANGELOG.md
git commit -m "Update changelog"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git master
455 changes: 286 additions & 169 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ processModules graph (dumpShunted, dumpTyped) =
>=> traverseGraphRevTopologically inferModule
>=> dumpIf fst dumpTyped (view (_Unwrapped % unlocated % field' @"name" % to nameText)) ".typed.elr"
>=> traverseGraphRevTopologically (\(a, b) -> moduleToCore b a)
>=> pure
. mapGraph coreToCore
>=> (pure . mapGraph coreToCore)
$ graph
)
where
Expand Down
119 changes: 119 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# git-cliff ~ default configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.

[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
Note that while Elara follows SemVer where possible, most of the source code is not considered public API with regards to breaking changes.
As such, breaking changes may occur between minor versions until a stable release of the language.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{%- macro remote_url() -%}
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
{%- endmacro -%}

{% macro print_commit(commit) -%}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }} - \
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
{% if commit.github.pr_number %} in #{{ commit.github.pr_number }}{%- endif %} \
{% endmacro -%}

{% if version %}\
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}]\
({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% endif %}\
{% else %}\
## [unreleased]
{% endif %}\

{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
{{ self::print_commit(commit=commit) }}
{%- endfor -%}
{% raw %}\n{% endraw %}\
{%- for commit in commits %}
{%- if not commit.scope -%}
{{ self::print_commit(commit=commit) }}
{% endif -%}
{% endfor -%}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing s
trim = true
# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
]

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = false
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# Replace issue numbers
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit with https://github.com/crate-ci/typos
# If the spelling is incorrect, it will be automatically fixed.
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
# filter out the commits that are not matched by commit parsers
filter_commits = false
# regex for matching git tags
# tag_pattern = "v[0-9].*"
# regex for skipping tags
# skip_tags = ""
# regex for ignoring tags
# ignore_tags = ""
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
# limit the number of commits included in the changelog.
# limit_commits = 42

[remote.github]
owner="elaralang"
repo="elara"
3 changes: 3 additions & 0 deletions elara.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ library
, safe-exceptions
, stringsearch
, terminal-size
, text-metrics
, utf8-string
mixins:
base hiding (Prelude)
Expand Down Expand Up @@ -231,6 +232,7 @@ executable elara
, safe-exceptions
, stringsearch
, terminal-size
, text-metrics
, utf8-string
mixins:
base hiding (Prelude)
Expand Down Expand Up @@ -312,6 +314,7 @@ test-suite elara-test
, safe-exceptions
, stringsearch
, terminal-size
, text-metrics
, utf8-string
mixins:
base hiding (Prelude)
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@

just-flake.features = {
treefmt.enable = true;
convco.enable = true;
};


Expand Down Expand Up @@ -156,6 +155,7 @@
pkgs.haskellPackages.haskell-debug-adapter
pkgs.haskellPackages.ghci-dap
pkgs.haskellPackages.hpack
pkgs.git-cliff
];
};

Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
- hashable
- process
- stringsearch
- text-metrics

ghc-options:
- -Wall
Expand Down
30 changes: 30 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# inspired by https://github.com/orhun/git-cliff/blob/main/release.sh

new_version=$(git cliff --bumped-version)
echo "New version: $new_version"

# update package.yaml version
sed -E -i '' "s/^version: \"[^\"]*\"$/version: \"${new_version#v}\"/" package.yaml
# and the cabal file
hpack


# Update changelog
git cliff --tag "${new_version}" > CHANGELOG.md
git add -A && git commit -m "chore(release): prepare for ${new_version}"
git show

# generate a changelog for the tag message
export GIT_CLIFF_TEMPLATE="\
{% for group, commits in commits | group_by(attribute=\"group\") %}
{{ group | upper_first }}\
{% for commit in commits %}
- {% if commit.breaking %}(breaking) {% endif %}{{ commit.message | upper_first }} ({{ commit.id | truncate(length=7, end=\"\") }})\
{% endfor %}
{% endfor %}"
changelog=$(git cliff --unreleased --strip all)

git tag -s -a "${new_version}" -m "Release ${new_version}" -m "${changelog}"
git tag -v "${new_version}"

echo "Release ready. Run 'git push --follow-tags' to push the changes and tags."
4 changes: 2 additions & 2 deletions source.elr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Prelude
import Option
import List
import Elara.Prim

let inc x = x + 1

let main =
print (Option.map inc (Some 5))
print (map incc (Some 5))
Loading
Loading