Skip to content

Commit

Permalink
ci: setup semantic-release & ex_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Nov 24, 2023
1 parent 6c522cc commit 8fcdad2
Show file tree
Hide file tree
Showing 10 changed files with 7,089 additions and 4 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,68 @@
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
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-name: mix-deps
with:
path: deps
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-${{ env.cache-name }}-

- name: Restore build cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-name: mix-build
with:
path: _build
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-${{ env.cache-name }}-

- 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 }}
75 changes: 75 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,75 @@
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

env:
MIX_ENV: test

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@78ecb5daf15aca198aeb2b6f208aabd06b2cb716 # v0.1.4
id: isInPR
outputs:
should-run: ${{ !(steps.isInPR.outputs.result == 'true' && github.event_name == 'push') }}

test:
name: Build and test

runs-on: ubuntu-latest
timeout-minutes: 5

needs: prevent-duplicate-checks
if: ${{ needs.prevent-duplicate-checks.outputs.should-run == 'true' }}

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

- name: Set up Elixir
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-name: mix-deps
with:
path: deps
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-${{ env.cache-name }}-

- name: Restore build cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
env:
cache-name: mix-build
with:
path: _build
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-${{ env.cache-name }}-

- name: Install dependencies
run: mix deps.get

- name: Check formatting
run: mix format --check-formatted

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

- name: Run tests
run: mix test
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -24,3 +24,6 @@ gpg_ex-*.tar

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

# Node.js dependencies directory
node_modules
50 changes: 50 additions & 0 deletions .releaserc
@@ -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"
}
]
]
}
1 change: 1 addition & 0 deletions .tool-versions
@@ -1,2 +1,3 @@
erlang 24.3.4
elixir 1.12.3
nodejs 20.10.0
4 changes: 2 additions & 2 deletions LICENSE.md
@@ -1,12 +1,12 @@
# License (Apache-2.0)
# License

Copyright (c) 2023 Pierre Cavin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
15 changes: 13 additions & 2 deletions mix.exs
Expand Up @@ -3,19 +3,27 @@ defmodule GPGex.MixProject do

@version "0.1.0"
@source_url "https://github.com/sheerlox/gpg_ex"
@docs_url "http://hexdocs.pm/gpg_ex"

def project do
[
app: :gpg_ex,
version: "0.1.0",
elixir: "~> 1.12.3 or ~> 1.13",
start_permanent: Mix.env() == :prod,
deps: deps(),
description: description(),
package: package(),
docs: docs()
]
end

defp deps do
[
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
]
end

defp description() do
"""
A simple wrapper to run GPG commands.
Expand All @@ -26,7 +34,10 @@ defmodule GPGex.MixProject do
[
maintainers: ["Pierre Cavin"],
licenses: ["Apache-2.0"],
links: %{"GitHub" => @source_url}
links: %{
GitHub: @source_url,
Changelog: "#{@docs_url}/changelog.html"
}
]
end

Expand All @@ -36,7 +47,7 @@ defmodule GPGex.MixProject do
main: "readme",
source_url: @source_url,
source_ref: "v#{@version}",
canonical: "http://hexdocs.pm/gpg_ex",
canonical: @docs_url,
extras: ["README.md", "CHANGELOG.md", "LICENSE.md"]
]
end
Expand Down
8 changes: 8 additions & 0 deletions mix.lock
@@ -0,0 +1,8 @@
%{
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"ex_doc": {:hex, :ex_doc, "0.30.9", "d691453495c47434c0f2052b08dd91cc32bc4e1a218f86884563448ee2502dd2", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d7aaaf21e95dc5cddabf89063327e96867d00013963eadf2c6ad135506a8bc10"},
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
}

0 comments on commit 8fcdad2

Please sign in to comment.