Publish an Elixir package to Hex.pm from an Umbrella app setup.
ref-name
configuration is used to identify which package you suppose to release. When the ref-name
matches the
following regex ^(.+)\@v([0-9]+\.[0-9]+\.[0-9])$
which is [package-name]@v[version]
, the package will be published
to Hex.pm if the package exists under the umbrella setup, and the version matches the existing package version in
the mix.exs
file.
For conveniently, the ref-name
value could be read from ${{ github.ref_name }}
context when reacting to a release
event.
- Create a Hex API Key following Publishing from CI .
- Add the Hex API Key
to GitHub Encrypted Secret
named
HEX_API_KEY
(or whichever name you prefer, but stick to the convention if possible).
-
Complete Add a HEX API Key to GitHub Secrets if required.
-
Make sure
actions/checkout
action is used before this action. -
Add this action to your job in your workflow, here is an example:
#... jobs: publish: name: Publish to Hex.pm runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 # checkout the repository first - uses: straw-hat-team/github-actions-workflows/elixir/umbrella-publish@master with: elixir-version: '1.11' # optional, fallback to use .tool-versions otp-version: '22.3' # optional, fallback to use .tool-versions version-type: 'loose' # optional, fallback to strict hex-api-key: ${{ secrets.HEX_API_KEY }} # (see step 2) ref-name: ${{ github.ref_name }} # the GitHub Release Tag Name with the format of "[package name]@v[version]"
-
Open the
mix.exs
file of the package you want to publish. -
Setup
source_url_pattern
ofdocs
as follows:defmodule MyPkgName.MixProject do use Mix.Project @app :my_pkg_name @version "0.7.3" @source_url "https://github.com/{owner}/{repo}" def project do [ # ... docs: [ source_url_pattern: "#{@source_url}/blob/#{@app}@v#{@version}/apps/#{@app}/%{path}#L%{line}" ], ] end end