Skip to content
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
61 changes: 57 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,78 @@ 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: 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
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
if: steps.check_release.outputs.release_created == 'true'
run: |
VERSION="${{ steps.get_version.outputs.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'
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
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand Down
28 changes: 24 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -29,9 +33,25 @@ 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}
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
{:git_hooks, "~> 0.7.3", only: [:dev], runtime: false},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
]
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
Loading