chore: update ci #23
Workflow file for this run
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
on: push | |
name: Privately published Elixir Library (with git ops) | |
env: | |
ELIXIR_VERSION: "1.12.3" | |
OTP_VERSION: "24.3.3" | |
jobs: | |
deps: | |
runs-on: ubuntu-20.04 | |
env: | |
NARRATIVE_HEX_ORG_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | |
MIX_ENV: test | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@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@v4 | |
with: | |
path: deps | |
key: ${{ runner.os }}-deps | |
- run: mix deps.get | |
- name: Uploading dependencies for other jobs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: deps | |
path: deps/ | |
build: | |
runs-on: ubuntu-20.04 | |
needs: ["deps"] | |
env: | |
MIX_ENV: test | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- name: Downloading dependencies | |
uses: actions/download-artifact@v4 | |
with: | |
name: deps | |
path: deps/ | |
- name: Downloading build artifact cache | |
uses: actions/cache@v4 | |
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@v4 | |
with: | |
name: build | |
path: _build/ | |
credo: | |
runs-on: ubuntu-20.04 | |
needs: ["deps", "build"] | |
env: | |
MIX_ENV: test | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- name: Downloading dependencies | |
uses: actions/download-artifact@v4 | |
with: | |
name: deps | |
path: deps/ | |
- name: Downloading build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: _build/ | |
- run: mix credo --strict | |
formatter: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- run: mix format --check-formatted | |
audit: | |
runs-on: ubuntu-20.04 | |
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@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@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@v4 | |
with: | |
name: deps | |
path: deps/ | |
- run: mix hex.audit | |
test: | |
runs-on: ubuntu-20.04 | |
needs: ["deps", "build"] | |
env: | |
MIX_ENV: test | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- name: Downloading dependencies | |
uses: actions/download-artifact@v4 | |
with: | |
name: deps | |
path: deps/ | |
- name: Downloading build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: _build/ | |
- run: mix test | |
is_releasable: | |
runs-on: ubuntu-20.04 | |
needs: ["deps", "test", "audit", "formatter", "credo"] | |
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/master'}} | |
env: | |
HEX_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- name: Downloading dependencies | |
uses: actions/download-artifact@v4 | |
with: | |
name: deps | |
path: deps/ | |
- name: Downloading build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: _build/ | |
- name: Getting app information | |
id: app-info | |
run: MIX_ENV=test mix git_ops.project_info --format github-actions | |
- name: Run mix hex.build | |
run: mix hex.build -o ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar | |
- name: Uploading hex package as job artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar | |
path: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.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@v4 | |
with: | |
name: ${{ steps.app-info.outputs.app_name }}-docs-${{ steps.app-info.outputs.app_version }}.tar.gz | |
path: docs.tar.gz | |
git_ops: | |
runs-on: ubuntu-20.04 | |
needs: ["deps", "test", "audit", "formatter", "credo"] | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
env: | |
HEX_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }} | |
steps: | |
- name: Checking out project | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: "Setting up Elixir" | |
uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ env.OTP_VERSION }} | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
- name: Downloading dependencies | |
uses: actions/download-artifact@v4 | |
with: | |
name: deps | |
path: deps/ | |
- name: Downloading build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: _build/ | |
- name: Configure git author | |
run: git config user.email '41898282+github-actions[bot]@users.noreply.github.com' ; git config user.name 'github-actions' | |
- name: Retrieving the current app version | |
id: original-app-info | |
run: MIX_ENV=test mix git_ops.project_info --format github-actions | |
- name: Run mix git_ops.release | |
run: MIX_ENV=test mix git_ops.release --yes || true | |
- name: Checking for new app version | |
id: app-info | |
run: MIX_ENV=test mix git_ops.project_info --format github-actions | |
- name: Building hex package | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
run: mix hex.build -o ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar | |
- name: Building hex docs | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
run: MIX_ENV=test mix docs && tar zcvf ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}-docs.tar.gz doc/ | |
- name: Pushing new tag | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
run: git push "https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}" HEAD:${{ github.ref }} refs/tags/v${{ steps.app-info.outputs.app_version }} | |
- name: Creating new Github release | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
id: create-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
tag_name: v${{ steps.app-info.outputs.app_version }} | |
release_name: Release ${{ steps.app-info.outputs.app_name }} ${{ steps.app-info.outputs.app_version }} | |
body: Autogenerated by git_ops release. | |
- name: Uploading hex package as release artifact | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
id: upload-package | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar | |
asset_name: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar | |
asset_content_type: application/x-tar | |
- name: Uploading documentation as release artifact | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
id: upload-docs | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}-docs.tar.gz | |
asset_name: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}-docs.tar.gz | |
asset_content_type: application/gzip | |
- name: Publishing hex package | |
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }} | |
run: mix hex.publish --organization narrativeapp --yes |