diff --git a/.github/workflows/docker.yml b/.github/workflows/docker_workflow.yml similarity index 65% rename from .github/workflows/docker.yml rename to .github/workflows/docker_workflow.yml index 2cb4635..cc14a38 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker_workflow.yml @@ -1,13 +1,16 @@ 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: @@ -15,10 +18,9 @@ jobs: 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 @@ -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 @@ -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 }} diff --git a/.github/workflows/docs_workflow.yml b/.github/workflows/docs_workflow.yml new file mode 100644 index 0000000..214ef03 --- /dev/null +++ b/.github/workflows/docs_workflow.yml @@ -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 diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index aed7c3d..026384d 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -2,7 +2,7 @@ name: IElixir CI on: push: - branches: [ master ] + branches: master pull_request: branches: - 'master' @@ -10,9 +10,22 @@ on: - '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] @@ -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 @@ -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 }} diff --git a/.github/workflows/generate_version.yml b/.github/workflows/generate_version.yml new file mode 100644 index 0000000..544223b --- /dev/null +++ b/.github/workflows/generate_version.yml @@ -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 + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45ec66f..ccb3efc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,8 +4,14 @@ 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 @@ -13,15 +19,25 @@ jobs: 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 diff --git a/VERSION b/VERSION index 3eefcb9..7dea76e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.0.1