Skip to content

Commit 4295c51

Browse files
committed
chore: Update README and add ci.
1 parent fbb030e commit 4295c51

File tree

3 files changed

+137
-1
lines changed

3 files changed

+137
-1
lines changed

.github/workflows/elixir.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Elixir CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
name: Build and test
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Elixir
22+
uses: erlef/setup-beam@v1
23+
with:
24+
elixir-version: "1.18.4"
25+
otp-version: "27"
26+
27+
- name: Install dependencies
28+
run: mix deps.get
29+
30+
- name: Run tests
31+
run: mix test
32+

.github/workflows/release.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-version:
7+
required: true
8+
description: 'The version of the release'
9+
default: '0.1.0'
10+
git-ref:
11+
required: true
12+
description: 'The git revison of repo, branch, tag or commit'
13+
default: 'main'
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
tests:
20+
name: Run tests (Elixir ${{matrix.elixir}}, OTP ${{matrix.otp}})
21+
22+
strategy:
23+
matrix:
24+
include:
25+
- elixir: 1.18
26+
otp: 27
27+
lint: lint
28+
29+
runs-on: ubuntu-latest
30+
31+
env:
32+
MIX_ENV: test
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ github.event.inputs.git-ref }}
39+
40+
- name: Set up Elixir
41+
uses: erlef/setup-beam@v1
42+
with:
43+
otp-version: ${{ matrix.otp }}
44+
elixir-version: ${{ matrix.elixir }}
45+
46+
- name: Install dependencies
47+
run: mix deps.get
48+
49+
- name: Check source code format
50+
run: mix format --check-formatted
51+
52+
- name: Remove compiled application files
53+
run: mix clean
54+
55+
- name: Compile & lint dependencies
56+
run: mix compile --warnings-as-errors
57+
58+
- name: Run tests
59+
run: mix test
60+
61+
release:
62+
name: Publish release to hex.pm
63+
runs-on: ubuntu-latest
64+
needs: [ tests ]
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
68+
steps:
69+
- name: 🛑 Cancel Previous Runs
70+
uses: styfle/[email protected]
71+
with:
72+
access_token: ${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: ⬇️ Checkout repo
75+
uses: actions/checkout@v4
76+
with:
77+
ref: ${{ github.event.inputs.git-ref }}
78+
79+
- name: Set up Elixir
80+
uses: erlef/setup-beam@v1
81+
with:
82+
otp-version: 27
83+
elixir-version: 1.18
84+
85+
- name: Install Deps
86+
run: |
87+
mix deps.get
88+
sed -i 's%@version "[0-9\.]\+"%@version "${{ github.event.inputs.release-version }}"%' mix.exs
89+
sed -i 's%{:phoenix_session_process, "~> [0-9\.]\+"}%{:phoenix_session_process, "~> ${{ github.event.inputs.release-version }}"}%' README.md
90+
91+
- name: Publish to hex.pm
92+
run: |
93+
mix hex.publish --yes
94+
95+
- name: Create Git Tag
96+
uses: actions/github-script@v7
97+
with:
98+
script: |
99+
github.rest.git.createRef({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
ref: 'refs/tags/${{ github.event.inputs.release-version }}',
103+
sha: context.sha
104+
})

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ The library handles:
102102
## License
103103

104104
MIT License
105-
EOF < /dev/null
105+

0 commit comments

Comments
 (0)