-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure CI and publish to hex. (#1)
* Configure for publishing to our private org on hex. * Add our github actions configuration and fix tests/credo.
- Loading branch information
Showing
7 changed files
with
343 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,276 @@ | ||
on: push | ||
|
||
name: Privately published Elixir Library | ||
|
||
env: | ||
ELIXIR_VERSION: "1.9" | ||
OTP_VERSION: "22.2" | ||
|
||
jobs: | ||
deps: | ||
runs-on: ubuntu-latest | ||
env: | ||
NARRATIVE_HEX_ORG_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | ||
MIX_ENV: test | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- name: Signing into narrativeapp organisation on hex | ||
run: mix hex.organization auth narrativeapp --key $NARRATIVE_HEX_ORG_API_KEY | ||
- name: Downloading dependency cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-deps | ||
- run: mix deps.get | ||
- name: Uploading dependencies for other jobs | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: ["deps"] | ||
env: | ||
MIX_ENV: test | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- name: Downloading dependencies | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
- name: Downloading build artifact cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: _build | ||
key: ${{ runner.os }}-build | ||
- name: Run `mix compile` | ||
run: mix compile | ||
- name: Uploading build artifacts for other jobs | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build | ||
path: _build/ | ||
|
||
credo: | ||
runs-on: ubuntu-latest | ||
needs: ["deps", "build"] | ||
env: | ||
MIX_ENV: test | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- name: Downloading dependencies | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
- name: Downloading build artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build | ||
path: _build/ | ||
- run: mix credo --strict | ||
|
||
formatter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- run: mix format --check-formatted | ||
|
||
audit: | ||
runs-on: ubuntu-latest | ||
needs: ["deps"] | ||
env: | ||
NARRATIVE_HEX_ORG_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | ||
MIX_ENV: test | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- run: mix hex.organization auth narrativeapp --key $NARRATIVE_HEX_ORG_API_KEY | ||
- name: Downloading dependencies | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
- run: mix hex.audit | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: ["deps", "build"] | ||
env: | ||
MIX_ENV: test | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- name: Downloading dependencies | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
- name: Downloading build artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build | ||
path: _build/ | ||
- run: mix test | ||
|
||
is_releasable: | ||
runs-on: ubuntu-latest | ||
needs: ["deps", "test", "audit", "formatter", "credo"] | ||
if: ${{ github.event_name == 'push' && !contains(github.ref, 'refs/tags/') }} | ||
env: | ||
HEX_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: Checking the app name | ||
id: app-name | ||
run: 'echo "::set-output name=app-name::$(awk -F''[:,]'' ''/app: /{print $3}'' mix.exs)"' | ||
- name: Checking the app version | ||
id: app-version | ||
run: "VERSION=$(awk -F\\\" '/version: /{print $2}' mix.exs); echo \"::set-output name=app-version::${VERSION}\"" | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- name: Downloading dependencies | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
- name: Downloading build artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build | ||
path: _build/ | ||
- name: Run mix hex.build | ||
run: mix hex.build -o ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
- name: Uploading hex package as job artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
path: ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
- name: Run mix docs | ||
run: MIX_ENV=test mix docs && tar zcvf docs.tar.gz doc/ | ||
- name: Uploading documentation as job artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.app-name.outputs.app-name }}-docs-${{ steps.app-version.outputs.app-version }}.tar.gz | ||
path: docs.tar.gz | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: ["deps", "test", "audit", "formatter", "credo"] | ||
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }} | ||
env: | ||
HEX_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | ||
steps: | ||
- name: Checking out project | ||
uses: actions/checkout@v2 | ||
- name: Checking the tag version | ||
id: tag-version | ||
run: VERSION=$(basename ${{ github.ref }}) ; echo "::set-output name=tag-version::${VERSION:1}" | ||
- name: Checking the app version | ||
id: app-version | ||
run: "VERSION=$(awk -F\\\" '/version: /{print $2}' mix.exs); echo \"::set-output name=app-version::${VERSION}\"" | ||
- name: Verifying that the git tag and the version in mix.exs match | ||
run: test "xx${{ steps.tag-version.outputs.tag-version }}" = "xx${{ steps.app-version.outputs.app-version }}" | ||
- name: Checking the app name | ||
id: app-name | ||
run: 'echo "::set-output name=app-name::$(awk -F''[:,]'' ''/app: /{print $3}'' mix.exs)"' | ||
- name: "Setting up Elixir" | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
- name: Downloading dependencies | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: deps | ||
path: deps/ | ||
- name: Downloading build artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build | ||
path: _build/ | ||
- name: Run mix hex.build | ||
run: mix hex.build -o ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
- name: Uploading hex package as job artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
path: ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
- name: Run mix docs | ||
run: MIX_ENV=test mix docs && tar zcvf docs.tar.gz doc/ | ||
- name: Uploading documentation as job artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.app-name.outputs.app-name }}-docs-${{ steps.app-version.outputs.app-version }}.tar.gz | ||
path: docs.tar.gz | ||
- name: Publishing hex package | ||
run: mix hex.publish --organization narrativeapp --yes | ||
- name: Creating new Github release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: v${{ steps.app-version.outputs.app-version }} | ||
release_name: Release ${{ steps.app-name.outputs.app-name }} ${{ steps.app-version.outputs.app-version }} | ||
body: Autogenerated from tag push | ||
- name: Uploading hex package as release artifact | ||
id: upload-package | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
asset_name: ${{ steps.app-name.outputs.app-name }}-${{ steps.app-version.outputs.app-version }}.tar | ||
asset_content_type: application/x-tar | ||
- name: Uploading documentation as release artifact | ||
id: upload-docs | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: docs.tar.gz | ||
asset_name: ${{ steps.app-name.outputs.app-name }}-docs-${{ steps.app-version.outputs.app-version }}.tar.gz | ||
asset_content_type: application/gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.