diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4624f66..97ef843 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,27 @@ name: CI -on: +on: push: + branches: [ main ] pull_request: - release: - types: - - published + workflow_call: jobs: + lint: + runs-on: ubuntu-latest + name: Linter + env: + MIX_ENV: test + steps: + - uses: actions/checkout@v3 + - uses: erlef/setup-beam@v1 + with: + otp-version: 25.0 + elixir-version: 1.14.0 + - run: mix deps.get + - run: mix compile --warnings-as-errors + - run: mix credo --strict --ignore design.tagtodo,readability.maxlinelength + test: services: postgres: @@ -25,40 +39,25 @@ jobs: --health-retries 5 strategy: matrix: - include: + version: - otp: 25.0 elixir: 1.14.0 os: ubuntu-latest - otp: 22.0 elixir: 1.12.0 - # It's necessary to run on ubuntu 20.04 for OTP 20 - 25 + # It's necessary to run on ubunto 20.04 for OTP 20 - 25 # See https://github.com/erlef/setup-beam - os: ubuntu-20.04 + os: ubuntu-20.04 runs-on: ${{ matrix.os }} - name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} - steps: - - uses: actions/checkout@v3 - - uses: erlef/setup-beam@v1 - with: - otp-version: ${{ matrix.otp }} - elixir-version: ${{ matrix.elixir }} - - run: mix deps.get - - run: mix test - env: - POSTGRES_URL: ecto://postgres:postgres@localhost/pow_assent_test - - run: MIX_ENV=test mix credo --ignore design.tagtodo,readability.maxlinelength --strict - deploy: - needs: test - runs-on: ubuntu-latest - if: github.event_name == 'release' && github.event.action == 'published' - name: Deploy published release + name: OTP ${{matrix.version.otp}} / Elixir ${{matrix.version.elixir}} env: - HEX_API_KEY: ${{secrets.HEX_API_KEY}} + MIX_ENV: test + POSTGRES_URL: ecto://postgres:postgres@localhost/pow_assent_test steps: - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 with: - otp-version: 24.0 - elixir-version: 1.12 - - run: mix deps.get - - run: mix hex.publish --yes + otp-version: ${{matrix.version.otp}} + elixir-version: ${{matrix.version.elixir}} + - run: mix deps.get mix compile --warnings-as-errors + - run: mix test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..749f622 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,25 @@ +name: Publish + +on: + release: + types: + - published + +jobs: + test: + uses: ./.github/workflows/ci.yml + + publish: + needs: test + runs-on: ubuntu-latest + name: Publish release + env: + HEX_API_KEY: ${{secrets.HEX_API_KEY}} + steps: + - uses: actions/checkout@v2 + - uses: erlef/setup-beam@v1 + with: + otp-version: 24.0 + elixir-version: 1.12 + - run: mix deps.get + - run: mix hex.publish --yes \ No newline at end of file