One single step to update version and publish on CD #18
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
name: Main CI | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
otp: ['22.3.4.26'] | |
elixir: ['1.8.2'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.8.2' | |
otp-version: '22.3.4.26' | |
version-type: 'strict' | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test/lib | |
key: ${{ runner.os }}-mix-test-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-mix-test- | |
- name: Install Dependencies | |
run: mix deps.get | |
- name: Build Dependencies | |
env: | |
MIX_ENV: test | |
run: mix deps.compile | |
- name: Build Yamel | |
env: | |
MIX_ENV: test | |
run: mix compile | |
lint: | |
runs-on: ubuntu-20.04 | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.8.2' | |
otp-version: '22.3.4.26' | |
version-type: 'strict' | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test/lib | |
key: ${{ runner.os }}-mix-test-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-mix-test- | |
- env: | |
MIX_ENV: test | |
run: mix format --check-formatted | |
test: | |
runs-on: ubuntu-20.04 | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.8.2' | |
otp-version: '22.3.4.26' | |
version-type: 'strict' | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test/lib | |
key: ${{ runner.os }}-mix-test-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-mix-test- | |
- run: mix test | |
coverage: | |
runs-on: ubuntu-20.04 | |
needs: test | |
env: | |
MIX_ENV: test | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.8.2' | |
otp-version: '22.3.4.26' | |
version-type: 'strict' | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test/lib | |
key: ${{ runner.os }}-mix-test-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
restore-keys: | | |
${{ runner.os }}-mix-test- | |
- name: Build ExCoveralls | |
run: mix compile excoveralls | |
- name: Coverage Summary | |
run: mix coveralls | |
- name: Publish Coverage | |
run: mix coveralls.github | |
trigger-cd: | |
runs-on: ubuntu-20.04 | |
needs: coverage | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_ACTIONS_USER }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Trigger CD | |
run: | | |
git config user.name Lucasbot | |
git config user.email [email protected] | |
if git tag releases/$(cat version); then | |
git push origin releases/$(cat version) -f | |
else | |
echo "Version already exists." | |
fi |