Skip to content

Commit

Permalink
feat: add release plugin version process
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Sep 24, 2024
1 parent 505e915 commit 6a868f1
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 6 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yml.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release Version

permissions:
contents: write

on:
workflow_dispatch:
push:
paths-ignore:
- "release.toml"
- "LICENS**"
- "README.md"
tags:
- "**"

jobs:
{% raw -%}
publish:
id: changelog
name: Publish Changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate a Changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
args: -vv --latest
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}
- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ contains(github.ref_name, 'a') }}
body: ${{ steps.git-cliff.outputs.content }}
{% endraw -%}

release-extension:
name: Release Zed Extension
needs: [changelog]
runs-on: ubuntu-latest
steps:
- uses: huacnlee/zed-extension-action@v1
with:
extension-name: {{plugin_id}}
push-to: {{username}}/extensions
env:
{%- raw %}
# the personal access token should have "repo" & "workflow" scopes
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
{% endraw -%}
17 changes: 11 additions & 6 deletions cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[template]
cargo_generate_version = ">=0.9.0"
exclude = [".github/workflows/ci.yml", "Readme.org"]
ignore = ["Readme.org"]
ignore = [".github/workflows/ci.yml", "Readme.org"]

[hooks]
post = ["post-script.rhai"]

[placeholders.license]
type = "string"
Expand All @@ -21,15 +23,18 @@ prompt = "Enter the name of your Zed extension"
type = "string"
prompt = "Enter a unique identifier for your plugin (e.g., 'my-awesome-plugin')"

[placeholders.plugin_type]
type = "string"
prompt = "What type of Zed plugin are you creating?"
choices = ["Language Server", "Theme", "Slash Command"]

[placeholders.deploy_release]
type = "bool"
prompt = "Would you like to set up GitHub releases for this plugin?"
default = true

[placeholders.plugin_type]
type = "string"
prompt = "What type of Zed plugin are you creating?"
choices = ["Language Server", "Theme", "Slash Command"]
[conditional.'!deploy_release']
ignore = [".github/workflows/release.yml", "cliff.toml", "release.toml"]

# Language Server Plugin
[conditional.'plugin_type == "Language Server"'.placeholders]
Expand Down
47 changes: 47 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# https://git-cliff.org/docs/configuration
[changelog]
header = ""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## New Version [{{ version | trim_start_matches(pat="v") }}]
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
footer = ""
trim = true

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
split_commits = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"
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" },
]
19 changes: 19 additions & 0 deletions post-script.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
let release = variable::get("deploy_release");

if release {
print(`
Post-Installation Instructions:

1. Set up the following environment variables in your GitHub Actions:
- COMMITTER_TOKEN: This should be a Personal Access Token (PAT) with repo and workflow scopes to authenticate the actions.

2. Configure cargo-release:
- Add release.toml to your project root for customizing the release process.
- To release a new version, run the following command:
cargo release -x patch|minor|major|alpha|beta

- This will handle version bumping, git tagging, and pushing new tags to the repository.

3. The release action in the workflow will automatically create a changelog and publish the release based on the tags pushed.
`);
}
4 changes: 4 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allow-branch = ["main", "dev", "!HEAD"]
publish = false
pre-release-commit-message = "chore: Release new version"
tag-name = "{{version}}"

0 comments on commit 6a868f1

Please sign in to comment.