release #7
This file contains hidden or 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
| name: release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release-version: | |
| required: true | |
| description: 'The version of the release' | |
| default: '0.1.0' | |
| git-ref: | |
| required: true | |
| description: 'The git revison of repo, branch, tag or commit' | |
| default: 'main' | |
| permissions: | |
| contents: write | |
| jobs: | |
| tests: | |
| name: Run tests (Elixir ${{matrix.elixir}}, OTP ${{matrix.otp}}) | |
| strategy: | |
| matrix: | |
| include: | |
| - elixir: 1.18 | |
| otp: 27 | |
| lint: lint | |
| runs-on: ubuntu-latest | |
| env: | |
| MIX_ENV: test | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.git-ref }} | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| otp-version: ${{ matrix.otp }} | |
| elixir-version: ${{ matrix.elixir }} | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Check source code format | |
| run: mix format --check-formatted | |
| - name: Remove compiled application files | |
| run: mix clean | |
| - name: Compile & lint dependencies | |
| run: mix compile --warnings-as-errors | |
| - name: Run tests | |
| run: mix test | |
| release: | |
| name: Publish release to hex.pm | |
| runs-on: ubuntu-latest | |
| needs: [ tests ] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HEX_API_KEY: ${{ secrets.HEX_API_KEY }} | |
| steps: | |
| - name: 🛑 Cancel Previous Runs | |
| uses: styfle/[email protected] | |
| with: | |
| access_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: ⬇️ Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.git-ref }} | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| otp-version: 27 | |
| elixir-version: 1.18 | |
| - name: Install Deps | |
| run: | | |
| mix deps.get | |
| sed -i 's%@version "[0-9\.]\+"%@version "${{ github.event.inputs.release-version }}"%' mix.exs | |
| sed -i 's%{:phoenix_session_process, "~> [0-9\.]\+"}%{:phoenix_session_process, "~> ${{ github.event.inputs.release-version }}"}%' README.md | |
| - name: Publish to hex.pm | |
| run: | | |
| mix hex.publish --yes | |
| - name: Create Git Tag | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'refs/tags/${{ github.event.inputs.release-version }}', | |
| sha: context.sha | |
| }) |