Skip to content

Commit

Permalink
feat: Add application.
Browse files Browse the repository at this point in the history
  • Loading branch information
GSMLG-BOT committed Jan 24, 2025
1 parent 5361ea5 commit b699cf8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 13 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/elixir_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-elixir@v1
uses: erlef/setup-beam@v1
with:
elixir-version: '1.14.3'
otp-version: '25.2'
elixir-version: 1.18
otp-version: 27

- name: Restore dependencies cache
uses: actions/cache@v3
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: release
on:
workflow_dispatch:
inputs:
release-version:
required: true
description: 'The version of the release'
default: '1.0.0'
git-ref:
required: true
description: 'The git revison of repo, branch, tag or commit'
default: 'main'

permissions:
contents: write

jobs:
release:
name: Publish release to hex.pm
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}

- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git-ref }}

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: 27
elixir-version: 1.18

- name: Install Deps
env:
MIX_ENV: prod
run: |
mix deps.get
sed -i 's%@version "[0-9\.]\+"%@version "${{ github.event.inputs.release-version }}"%' mix.exs
sed -i 's%{:phoenix_react_server, "~> [0-9\.]\+"}%{:phoenix_react_server, "~> ${{ github.event.inputs.release-version }}"}%' README.md
- name: Publish to hex.pm
env:
MIX_ENV: prod
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
run: |
mix hex.publish --yes
- uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ github.event.inputs.release-version }}',
sha: context.sha
})
16 changes: 16 additions & 0 deletions lib/caddy/application.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Caddy.Application do
@moduledoc false

use Application

@impl true
def start(_type, args) do
children = [
{Caddy, args},
]

opts = [strategy: :one_for_one, name: Caddy.Application]
Supervisor.start_link(children, opts)
end

end
17 changes: 8 additions & 9 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
defmodule Caddy.MixProject do
use Mix.Project

@source_url "https://github.com/gsmlg-dev/elixir_caddy.git"
@version "1.0.7"

def project do
[
app: :caddy,
version: "1.0.7",
version: @version,
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
name: "Caddy",
description: "Run Caddy HTTP Server in supervisor tree",
description: "Run Caddy Reverse Proxy Server in supervisor tree",
aliases: aliases(),
package: package(),
deps: deps()
Expand All @@ -35,18 +38,14 @@ defmodule Caddy.MixProject do
[
maintainers: ["Jonathan Gao"],
licenses: ["MIT"],
files: ~w(lib priv LICENSE mix.exs README.md),
files: ~w(lib LICENSE mix.exs README.md),
links: %{
Github: @source_url,
Changelog: "https://hexdocs.pm/caddy/changelog.html"
}
]
end

# Aliases are shortcuts or tasks specific to the current project.
# For example, publish this package, run:
#
# $ mix publish
#
defp aliases do
[
setup: ["deps.get", "assets.setup"],
Expand All @@ -56,7 +55,7 @@ defmodule Caddy.MixProject do
File.rm_rf!("priv")
File.mkdir!("priv")
end,
"hex.publish"
"hex.publish --yes"
]
]
end
Expand Down

0 comments on commit b699cf8

Please sign in to comment.