From b7b38720cad91c5ee85b3a3ceb3d21c337970b0a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 08:49:42 +0000 Subject: [PATCH 1/5] Initial plan From c4d2cfd31403f3c895bf90e56de0cefce193c375 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 08:53:51 +0000 Subject: [PATCH 2/5] feat: add Hex.pm publishing to release workflow - Add package metadata to mix.exs (description, package, links, licenses) - Update release workflow to publish to Hex.pm after semantic-release - Add ex_doc dependency for documentation generation - Update CONTRIBUTING.md with Hex.pm publishing information Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++---- CONTRIBUTING.md | 12 ++++++++--- mix.exs | 26 +++++++++++++++++++++-- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe525f6..2586015 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,25 +11,57 @@ jobs: name: Release runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip ci')" - + steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 persist-credentials: false - + - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: '18' - + - name: Install semantic-release run: | npm install -g \ semantic-release@21 - + - name: Run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release + + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: '1.14.2' + otp-version: '25.1.1' + + - name: Get latest release version + id: get_version + run: | + # Fetch all tags + git fetch --tags + # Get the latest tag + VERSION=$(git describe --tags --abbrev=0) + # Remove 'v' prefix if present + VERSION=${VERSION#v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Latest version: $VERSION" + + - name: Update version in mix.exs + run: | + VERSION="${{ steps.get_version.outputs.version }}" + sed -i "s/version: \".*\"/version: \"$VERSION\"/" mix.exs + cat mix.exs | grep version: + + - name: Install dependencies + run: mix deps.get + + - name: Publish to Hex.pm + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + run: mix hex.publish --yes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9f16f77..52a209c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,11 +107,17 @@ Releases are automated using [semantic-release](https://semantic-release.gitbook 2. Semantic-release analyzes commit messages since the last release 3. If releasable commits are found: - A new version is determined based on commit types - - The version in `mix.exs` is updated - - A `CHANGELOG.md` is generated/updated - A Git tag is created - A GitHub release is published - - Changes are committed back to the repository + - The package is published to [Hex.pm](https://hex.pm/packages/acx) + +### Hex.pm Publishing + +The release workflow automatically publishes new versions to Hex.pm. This requires a `HEX_API_KEY` secret to be configured in the repository settings: + +1. Generate an API key from your Hex.pm account +2. Add it as a repository secret named `HEX_API_KEY` +3. The workflow will use this key to authenticate and publish the package ## Pull Request Process diff --git a/mix.exs b/mix.exs index 20f0a87..b26f17f 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,11 @@ defmodule Acx.MixProject do elixir: "~> 1.13", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, - deps: deps() + deps: deps(), + description: description(), + package: package(), + source_url: "https://github.com/casbin/casbin-ex", + homepage_url: "https://casbin.org" ] end @@ -29,9 +33,27 @@ defmodule Acx.MixProject do [ {:ecto_sql, "~> 3.10"}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, - {:git_hooks, "~> 0.7.3", only: [:dev], runtime: false} + {:git_hooks, "~> 0.7.3", only: [:dev], runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end + + defp description() do + "Casbin-Ex is a powerful and efficient open-source access control library for Elixir projects." + end + + defp package() do + [ + name: "acx", + files: ~w(lib .formatter.exs mix.exs README.md LICENSE), + licenses: ["Apache-2.0"], + links: %{ + "GitHub" => "https://github.com/casbin/casbin-ex", + "Homepage" => "https://casbin.org", + "Docs" => "https://casbin.org/docs/overview" + } + ] + end end From 7499c0ef0fdebdc6e3a1d02ed5a217a2ebe76797 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 08:55:28 +0000 Subject: [PATCH 3/5] docs: update installation instructions to prioritize Hex.pm Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 17d7b90..59d723d 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,18 @@ https://casbin.org/docs/overview ## Installation +The package can be installed by adding `acx` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:acx, "~> 1.6"} + ] +end +``` + +Or install from GitHub: + ```elixir def deps do [ From 2da4317eb9d2f56bfcb07f333f9548ed88a2169f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 08:56:34 +0000 Subject: [PATCH 4/5] feat: add conditional check to only publish to Hex when release is created Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- .github/workflows/release.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2586015..99cee01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,17 +30,34 @@ jobs: semantic-release@21 - name: Run semantic-release + id: semantic_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release + - name: Check if release was created + id: check_release + run: | + # Get the current commit SHA + CURRENT_SHA=$(git rev-parse HEAD) + # Check if there's a tag pointing to this commit + if git describe --exact-match --tags $CURRENT_SHA 2>/dev/null; then + echo "release_created=true" >> $GITHUB_OUTPUT + echo "Release was created" + else + echo "release_created=false" >> $GITHUB_OUTPUT + echo "No release was created" + fi + - name: Set up Elixir + if: steps.check_release.outputs.release_created == 'true' uses: erlef/setup-beam@v1 with: elixir-version: '1.14.2' otp-version: '25.1.1' - name: Get latest release version + if: steps.check_release.outputs.release_created == 'true' id: get_version run: | # Fetch all tags @@ -53,15 +70,18 @@ jobs: echo "Latest version: $VERSION" - name: Update version in mix.exs + if: steps.check_release.outputs.release_created == 'true' run: | VERSION="${{ steps.get_version.outputs.version }}" sed -i "s/version: \".*\"/version: \"$VERSION\"/" mix.exs cat mix.exs | grep version: - name: Install dependencies + if: steps.check_release.outputs.release_created == 'true' run: mix deps.get - name: Publish to Hex.pm + if: steps.check_release.outputs.release_created == 'true' env: HEX_API_KEY: ${{ secrets.HEX_API_KEY }} run: mix hex.publish --yes From bfbd2d71321d174da47075917ce3bda8020364e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 08:58:49 +0000 Subject: [PATCH 5/5] refactor: address code review feedback - Remove unused id from semantic-release step - Improve sed pattern specificity for version update - Remove unnecessary comment lines from deps Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com> --- .github/workflows/release.yml | 7 ++++--- mix.exs | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99cee01..90e9c3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,6 @@ jobs: semantic-release@21 - name: Run semantic-release - id: semantic_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release @@ -73,8 +72,10 @@ jobs: if: steps.check_release.outputs.release_created == 'true' run: | VERSION="${{ steps.get_version.outputs.version }}" - sed -i "s/version: \".*\"/version: \"$VERSION\"/" mix.exs - cat mix.exs | grep version: + # Update the version in the project configuration + sed -i "s/^\s*version: \"[^\"]*\"/ version: \"$VERSION\"/" mix.exs + echo "Updated version to:" + cat mix.exs | grep "version:" - name: Install dependencies if: steps.check_release.outputs.release_created == 'true' diff --git a/mix.exs b/mix.exs index b26f17f..b87edf0 100644 --- a/mix.exs +++ b/mix.exs @@ -35,8 +35,6 @@ defmodule Acx.MixProject do {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:git_hooks, "~> 0.7.3", only: [:dev], runtime: false}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} - # {:dep_from_hexpm, "~> 0.3.0"}, - # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end