Skip to content

Commit

Permalink
chore: Add generate_version.yml pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
pprzetacznik committed Mar 28, 2024
1 parent 92fe5e8 commit d907008
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
name: IElixir Docker

on:
push:
branches: master
pull_request:
branches:
- 'master'
- 'feature/**'
- 'fix/**'
workflow_call:
inputs:
version:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout IElixir project
uses: actions/checkout@v2
- name: Generate version
id: gen_ielixir_version
- name: Set version
run: |
echo "IELIXIR_VERSION=$(cat ./VERSION).$(date '+%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
echo ${{ inputs.version }} >> VERSION
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
Expand All @@ -34,7 +36,7 @@ jobs:
with:
push: true
file: ./docker/ielixir-requirements/Dockerfile
tags: pprzetacznik/ielixir-requirements:${{ steps.gen_ielixir_version.outputs.IELIXIR_VERSION }}
tags: pprzetacznik/ielixir-requirements:${{ inputs.version }}
build-args: |
ERL_VERSION=26.2.3
ELIXIR_VERSION=1.14.2
Expand All @@ -44,8 +46,8 @@ jobs:
with:
push: true
file: ./docker/ielixir/Dockerfile
tags: pprzetacznik/ielixir:${{ steps.gen_ielixir_version.outputs.IELIXIR_VERSION }}
tags: pprzetacznik/ielixir:${{ inputs.version }}
build-args: |
IELIXIR_REQUIREMENTS_DOCKER_VERSION=${{ steps.gen_ielixir_version.outputs.IELIXIR_VERSION }}
IELIXIR_REQUIREMENTS_DOCKER_VERSION=${{ inputs.version }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
40 changes: 40 additions & 0 deletions .github/workflows/docs_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: IElixir generate documentation

on:
workflow_call:
inputs:
version:
required: true
type: string
secrets:
GH_TOKEN:
required: true

jobs:
docs:
name: Documentation and coverage reports
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout IElixir project
uses: actions/checkout@v2
- name: Set version
run: |
echo ${{ inputs.version }} > VERSION
- name: Install prerequisites
run: |
sudo apt install -y openssl libncurses5
sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: 'OTP-26.0'
elixir-version: 'v1.14-otp-26'
- name: Generate documentation
run: |
MIX_ENV=docs mix deps.get
MIX_ENV=docs mix compile
MIX_ENV=docs mix docs
MIX_ENV=docs mix inch.report
MIX_ENV=test mix coveralls.github
46 changes: 23 additions & 23 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,30 @@ name: IElixir CI

on:
push:
branches: [ master ]
branches: master
pull_request:
branches:
- 'master'
- 'feature/**'
- 'fix/**'

jobs:
generate_version:
uses: ./.github/workflows/generate_version.yml

build_docker:
uses: ./.github/workflows/docker_workflow.yml
needs: generate_version
with:
version: ${{ needs.generate_version.outputs.version }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

build:
name: Build and test
runs-on: ${{ matrix.os }}
needs: generate_version
strategy:
matrix:
os: [ubuntu-22.04]
Expand All @@ -22,6 +35,9 @@ jobs:
steps:
- name: Checkout IElixir project
uses: actions/checkout@v2
- name: Set version
run: |
echo ${{ needs.generate_version.outputs.build_version }} > VERSION
- name: Install prerequisites
run: |
sudo apt install -y openssl libncurses5
Expand Down Expand Up @@ -56,25 +72,9 @@ jobs:
MIX_ENV=dev python jupyter_kernel_test/test_ielixir.py
docs:
name: Documentation and coverage reports
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Install prerequisites
run: |
sudo apt install -y openssl libncurses5
sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: 'OTP-26.0'
elixir-version: 'v1.14-otp-26'
- name: Generate documentation
run: |
MIX_ENV=docs mix deps.get
MIX_ENV=docs mix compile
MIX_ENV=docs mix docs
MIX_ENV=docs mix inch.report
MIX_ENV=test mix coveralls.github
uses: ./.github/workflows/docs_workflow.yml
needs: generate_version
with:
version: ${{ needs.generate_version.outputs.version }}
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/generate_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Reusable version generation workflow

on:
workflow_call:
outputs:
version:
description: "Generated version"
value: ${{ jobs.generate_version.outputs.version }}
build_version:
description: "Generated build version"
value: ${{ jobs.generate_version.outputs.build_version }}
is_release:
description: "Generated is release flag"
value: ${{ jobs.generate_version.outputs.is_release }}

jobs:
generate_version:
name: Generate version job
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gen_ielixir_version.outputs.IELIXIR_VERSION }}
build_version: ${{ steps.gen_ielixir_version.outputs.IELIXIR_BUILD_VERSION }}
is_release: ${{ steps.gen_ielixir_version.outputs.IELIXIR_IS_RELEASE }}
steps:
- name: Checkout IElixir project
uses: actions/checkout@v2
- name: Generate version
id: gen_ielixir_version
run: |
echo "IELIXIR_VERSION=$(cat ./VERSION)" >> $GITHUB_OUTPUT
echo "IELIXIR_BUILD_VERSION=$(cat ./VERSION)+dev$(date '+%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: Check if release
id: check_if_release
run: |
echo "${{ github.ref }}"
echo "IELIXIR_IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}" >> $GITHUB_OUTPUT
- name: Print flags
run: |
cat $GITHUB_OUTPUT
echo $GITHUB_OUTPUT
24 changes: 20 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,40 @@ on:
push:
tags:
- 'v*'
pull_request:
branches:
- 'feature/**'

jobs:
generate_version:
uses: ./.github/workflows/generate_version.yml

release:
name: Documentation and coverage reports
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
steps:
- uses: actions/checkout@v2
- name: Checkout IElixir project
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set version
run: |
echo ${{ needs.generate_version.outputs.version }} > VERSION
python -c 'import sys; a, b, c = sys.stdin.read().strip().split("."); print(f"{a}.{b}.{int(c)+1}")' < VERSION > VERSION
- name: Install prerequisites
run: |
sudo apt install -y openssl libncurses5
sudo apt install -y libzmq3-dev libsqlite3-dev libssl-dev
- name: Set up Elixir
uses: actions/setup-elixir@v1
uses: erlef/setup-beam@v1
with:
elixir-version: '1.14'
otp-version: '26'
otp-version: 'OTP-${{ matrix.otp-version }}'
elixir-version: 'v${{ matrix.elixir-version }}-otp-${{ matrix.otp-version }}'
- name: Generate documentation
run: |
MIX_ENV=docs mix deps.get
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1

0 comments on commit d907008

Please sign in to comment.