From d403174da6ca795083da744f49a6f83275c30754 Mon Sep 17 00:00:00 2001 From: Enrique Fernandez Date: Thu, 9 May 2024 18:35:47 +0200 Subject: [PATCH] build: automate publishing of hex package --- .github/workflows/publish.yml | 18 ++++++++++++++++++ .rc | 2 +- Makefile | 5 ++++- mix.exs | 18 +++++++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..af0912f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +name: publish + +on: + release: + types: [created] + +jobs: + build: + name: publish package to hex + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: publish package to hex + shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' + run: make publish + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} diff --git a/.rc b/.rc index f41948c..8a168fa 100644 --- a/.rc +++ b/.rc @@ -1,7 +1,7 @@ function mix() { ELIXIR_VERSION=${ELIXIR_VERSION:-1.15.6} DOCKER_IMAGE=elixir:${ELIXIR_VERSION} - DOCKER_RUN_OPTS="--rm -it --network host -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u):$(id -g) -v ${PWD}:${PWD} -w ${PWD} -e HEX_HOME=${PWD} -e MIX_HOME=${PWD} -e UOF_BASE_URL -e UOF_AUTH_TOKEN ${DOCKER_RUN_EXTRA_OPTS}" + DOCKER_RUN_OPTS="--rm -it --network host -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u):$(id -g) -v ${PWD}:${PWD} -w ${PWD} -e HEX_HOME=${PWD} -e MIX_HOME=${PWD} -e UOF_BASE_URL -e UOF_AUTH_TOKEN -e HEX_API_KEY ${DOCKER_RUN_EXTRA_OPTS}" if [ -n "$ZSH_VERSION" ]; then docker run ${=DOCKER_RUN_OPTS} ${DOCKER_IMAGE} mix "$@" else diff --git a/Makefile b/Makefile index 951a4d5..e13500b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all deps compile format test docs shell +.PHONY: all deps compile format test docs shell publish ifndef NODOCKER SHELL := BASH_ENV=.rc /bin/bash --noprofile @@ -27,3 +27,6 @@ docs: shell: compile iex -S mix + +publish: + mix hex.publish --yes --dry-run diff --git a/mix.exs b/mix.exs index ae63fee..0e9fde6 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,11 @@ defmodule UofApi.MixProject do version: "1.0.0", elixir: "~> 1.15", start_permanent: Mix.env() == :prod, - deps: deps() + description: description(), + package: package(), + deps: deps(), + name: "UOF API", + source_url: "https://github.com/efcasado/uof_api" ] end @@ -28,4 +32,16 @@ defmodule UofApi.MixProject do {:mock, "~> 0.3.8", only: :test} ] end + + defp description() do + "An Elixir client for Betradar's Unified Odds Feed (UOF) API" + end + + defp package() do + [ + name: "UOF API", + licenses: ["MIT"], + links: %{"GitHub" => "https://github.com/efcasado/uof_api"} + ] + end end