Skip to content

.github/workflows/release-eibisqlite.yml #820

.github/workflows/release-eibisqlite.yml

.github/workflows/release-eibisqlite.yml #820

on:
workflow_dispatch:
schedule:
- cron: '00 20 * * *'
jobs:
create_version:
runs-on: ubuntu-20.04
name: Create new eibi sqlite version if necessary
outputs:
has_to_create_new_version: ${{ fromJson(steps.create_version.outputs.create_version).updated }}
machine_name_for_period: ${{ fromJson(steps.create_version.outputs.create_version).machine_name_for_period }}
last_update: ${{ fromJson(steps.create_version.outputs.create_version).last_update }}
filename: ${{ fromJson(steps.create_version.outputs.create_version).filename }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: erlef/setup-beam@v1
with:
otp-version: '24'
elixir-version: '1.13.0'
- name: Retrieve cached dependencies
uses: actions/cache@v3
id: mix-cache
with:
path: |
deps
_build
priv/plts
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }}
- name: Install dependencies if not in cache
if: steps.mix-cache.outputs.cache-hit != 'true'
run: |
mix deps.get
mix deps.compile
- name: Compile
run: mix compile
- name: Run create version task
id: create_version
run: echo "create_version=$(mix create_version)" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: eibisqlite
path: tmp/eibi.sqlite
release:
needs: create_version
runs-on: ubuntu-20.04
name: Release new eibisqlite
if: ${{ needs.create_version.outputs.has_to_create_new_version == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Bump file version
run: |
sed -i 's/ latest: ".*"/ latest: "${{ needs.create_version.outputs.filename }}"/g' config/config.exs
sed -i 's/ last_update: ".*"/ last_update: "${{ needs.create_version.outputs.last_update }}"/g' config/config.exs
git config --global user.name 'jmisasa'
git config --global user.email 'jmisasa@users.noreply.github.com'
git add config/config.exs
git commit -m "generate new release ${{ needs.create_version.outputs.filename }} - ${{ needs.create_version.outputs.last_update }}"
git push origin master
- name: Tag release
id: tag_release
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: eibisqlite
- name: Make release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_release.outputs.new_tag }}
files: eibi.sqlite
name: ${{ needs.create_version.outputs.machine_name_for_period }}-${{ needs.create_version.outputs.last_update }}
body: Shortwave schedules from EiBi files for period ${{ needs.create_version.outputs.machine_name_for_period }} (file date ${{ needs.create_version.outputs.last_update }})