Skip to content

Commit

Permalink
chore: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Nov 29, 2023
0 parents commit c098b8c
Show file tree
Hide file tree
Showing 15 changed files with 7,313 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
push:
branches:
- main
- dev

permissions:
contents: read

jobs:
test:
uses: ./.github/workflows/test.yml
permissions:
contents: read

release:
needs: test

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
persist-credentials: false

- name: Set up Elixir
id: setup-beam
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
version-type: strict
version-file: .tool-versions

- name: Restore dependencies cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: deps
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
restore-keys: |
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}
path: |
deps
_build
- name: Install dependencies
run: |
mix local.hex --force
mix do deps.get, deps.compile
- name: Use Node.js LTS
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version-file: ".tool-versions"

- name: Install packages
run: npm ci

- name: Audit npm signatures
run: npm audit signatures

- name: Run Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
141 changes: 141 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Test

on:
push:
# ignore branches where the release workflow runs as it already calls this one
branches-ignore:
- main
- dev
pull_request:
workflow_call:

permissions:
contents: read

jobs:
# ignore the push event trigger if a PR is open for the current branch
prevent_duplicate_checks:
runs-on: ubuntu-latest
steps:
- uses: insurgent-lab/is-in-pr-action@3e01b38aa0d2a0e51bbc84540300303ec850e80d # v0.1.5
id: isInPR
outputs:
should-run: ${{ !(steps.isInPR.outputs.result == 'true' && github.event_name == 'push') }}

test_matrix:
name: Test (Elixir ${{matrix.elixir}} | OTP ${{matrix.otp}})

runs-on: ${{ matrix.os }}
timeout-minutes: 10

needs: prevent_duplicate_checks
if: ${{ needs.prevent_duplicate_checks.outputs.should-run == 'true' }}

strategy:
fail-fast: false
matrix:
include:
- elixir: 1.12.x
otp: 22
os: ubuntu-20.04
- elixir: 1.13.x
otp: 23
os: ubuntu-20.04
- elixir: 1.14.x
otp: 24
os: ubuntu-22.04
- elixir: 1.15.x
otp: 25
os: ubuntu-22.04
- elixir: 1.16.x
otp: 26
os: ubuntu-latest

env:
MIX_ENV: test

steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up BEAM
id: setup-beam
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}

- name: Restore dependencies cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: deps
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
restore-keys: |
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}
path: |
deps
_build
- name: Install dependencies
run: |
mix local.hex --force
mix do deps.get, deps.compile
- name: Check formatting
run: mix format --check-formatted

- name: Compile code (without warning)
run: mix compile --warnings-as-errors

- name: Run tests
run: mix test

# Dialyzer

- name: Restore PLTs cache
id: restore_plts_cache
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: plts
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
restore-keys: |
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}
${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}
path: priv/plts

- name: Create PLTs
if: steps.restore_plts_cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts/core.plt
mix dialyzer --plt
- name: Save PLTs cache
uses: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-key: plts
if: steps.restore_plts_cache.outputs.cache-hit != 'true'
with:
key: ${{ env.cache-key }}-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-git-${{ github.sha }}
path: priv/plts

- name: Run dialyzer
run: mix dialyzer --format github

# separate job to set as required status check in branch protection
required_check:
runs-on: ubuntu-latest
needs:
- prevent_duplicate_checks
- test_matrix

if: ${{ !cancelled() && needs.prevent_duplicate_checks.outputs.should-run == 'true' }}
steps:
- name: All required jobs and matrix versions passed
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Some required jobs or matrix versions failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
semantic_release-*.tar

# Temporary files, for example, from tests.
/tmp/

# Node.js dependencies directory
node_modules

# Dialyzer
/priv/plts/*.plt
/priv/plts/*.plt.hash
50 changes: 50 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"branches": [
"main",
{
"name": "dev",
"prerelease": "alpha",
"channel": "alpha"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"config": "@insurgent/conventional-changelog-preset",
"releaseRules": "@insurgent/conventional-changelog-preset/release-rules"
}
],
[
"@semantic-release/release-notes-generator",
{
"config": "@insurgent/conventional-changelog-preset"
}
],
[
"@semantic-release/changelog",
{
"changelogTitle": "# Changelog"
}
],
"semantic-release-hex",
[
"@semantic-release/git",
{
"assets": [
"mix.exs",
"README.md",
"CHANGELOG.md"
],
"message": "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github",
[
"@semantic-release/exec",
{
"publishCmd": "mix hex.publish --yes"
}
]
]
}
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
erlang 24.3.4
elixir 1.12.3
nodejs 20.9.0
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# License

Copyright (c) 2023 Talent Ideal

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Semantic Release for Elixir

Mix tasks for installing and running [`semantic-release`](https://github.com/semantic-release/semantic-release/) (and the adapter plugin [`semantic-release-hex`](https://github.com/talent-ideal/semantic-release-hex/)) in Elixir projects.

> **⚠️ WARNING**
>
> This is a pre-release version. As such, anything _may_ change
> at any time, the public API _should not_ be considered stable,
> and using a pinned version is _recommended_.
Full documentation can be found at [https://hexdocs.pm/semantic_release](https://hexdocs.pm/semantic_release).

## Installation

`gpg` must be available in your PATH to verify the signature of Node.js releases.

The package can be installed by adding `semantic_release` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:semantic_release, "0.1.0", only: :dev, runtime: false}
]
end
```

## Versioning

This project follows the principles of [Semantic Versioning (SemVer)](https://semver.org/).
18 changes: 18 additions & 0 deletions lib/semantic_release.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule SemanticRelease do
@moduledoc """
Documentation for `SemanticRelease`.
"""

@doc """
Hello world.
## Examples
iex> SemanticRelease.hello()
:world
"""
def hello do
:world
end
end
Loading

0 comments on commit c098b8c

Please sign in to comment.