Repository: activeviam/jdk4py (language: python)

Issue:
Factorise code in github workflows
All the jobs starts with the same set of steps to setup every thing:

```yaml
      - uses: actions/checkout@v2

      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}
          architecture: "x64"

      - name: Set Java version
        run: python scripts/set_versions.py

      - uses: joschi/setup-jdk@v2 # We must use to the official action once https://github.com/actions/setup-java/pull/97 is closed
        with:
          java-version: ${{ env.MAJOR_JAVA_VERSION }}
          java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
          architecture: x64

      # Install Poetry
      - if: matrix.os == 'windows-latest'
        name: Install poetry [Windows]
        run: pip install poetry
      - if: matrix.os != 'windows-latest'
        name: Install poetry [Ubuntu/macOS]
        run: pip3 install poetry

      - name: Install python dependencies
        run: poetry install

      - name: Build JDK
        run: poetry run python scripts/build_jdk.py
```

We should factorize it to avoid changing the same thing multiple times.

I have tried putting them into a [composite action](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-composite-run-steps-action) but it doesn't support the `uses` steps


Discussion / hints:
Related issue: https://github.com/actions/runner/issues/646.

Fix patch:
diff --git a/.github/actions/build-jdk/action.yaml b/.github/actions/build-jdk/action.yaml
new file mode 100644
index 0000000..26fbf9b
--- /dev/null
+++ b/.github/actions/build-jdk/action.yaml
@@ -0,0 +1,34 @@
+name: Build JDK
+description: Install the dependencies and build the JDK
+inputs:
+  python-version:
+    description: The version of Python to set up.
+    required: true
+runs:
+  using: "composite"
+  steps:
+    - uses: actions/setup-python@v2
+      with:
+        architecture: x64
+        python-version: ${{ inputs.python-version }}
+
+    - name: Install Poetry
+      shell: bash
+      run: pip install poetry
+
+    - name: Install Python dependencies
+      shell: bash
+      run: poetry install
+
+    - name: Set environment variables
+      shell: bash
+      run: poetry run python scripts/set_environment.py
+
+    - uses: actions/setup-java@v2
+      with:
+        distribution: adopt
+        java-version: ${{ env.JDK4PY_JAVA_VERSION }}
+
+    - name: Build JDK
+      shell: bash
+      run: poetry run python scripts/build_jdk.py
diff --git a/.github/actions/create-conda-package/action.yaml b/.github/actions/create-conda-package/action.yaml
new file mode 100644
index 0000000..d68c6f4
--- /dev/null
+++ b/.github/actions/create-conda-package/action.yaml
@@ -0,0 +1,13 @@
+name: Create Conda package
+description: Create a Conda package
+runs:
+  using: "composite"
+  steps:
+    - uses: conda-incubator/setup-miniconda@v2
+      with:
+        channels: conda-forge
+        conda-build-version: "3.21.5"
+
+    - name: Create Conda package
+      shell: bash
+      run: conda build --no-anaconda-upload --output-folder dist .
diff --git a/.github/actions/create-python-wheel/action.yaml b/.github/actions/create-python-wheel/action.yaml
new file mode 100644
index 0000000..a9da6e7
--- /dev/null
+++ b/.github/actions/create-python-wheel/action.yaml
@@ -0,0 +1,8 @@
+name: Create Python wheel
+description: Create a Python wheel
+runs:
+  using: "composite"
+  steps:
+    - name: Build Python wheel
+      shell: bash
+      run: poetry run python setup.py bdist_wheel --build-number $JDK4PY_BUILD_NUMBER
diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml
index e6e520f..4f383c8 100644
--- a/.github/workflows/deployment.yaml
+++ b/.github/workflows/deployment.yaml
@@ -15,46 +15,20 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
-      - uses: actions/setup-python@v2
+      - uses: ./.github/actions/build-jdk
         with:
-          architecture: x64
           python-version: "3.9"
 
-      - name: Install Poetry
-        run: pip install poetry
+      - uses: ./.github/actions/create-python-wheel
 
-      - name: Install Python dependencies
-        run: poetry install
+      - uses: ./.github/actions/create-conda-package
 
-      - name: Set environment variables
-        run: poetry run python scripts/set_environment.py
-
-      - uses: actions/setup-java@v2
-        with:
-          distribution: adopt
-          java-version: ${{ env.JDK4PY_JAVA_VERSION }}
-
-      - name: Build JDK
-        run: poetry run python scripts/build_jdk.py
-
-      - name: Build Python wheel
-        shell: bash
-        run: poetry run python setup.py bdist_wheel --build-number $JDK4PY_BUILD_NUMBER
-
-      - name: Deploy to PyPI
+      - name: Upload Python wheel
         env:
           TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
         shell: bash
         run: poetry run twine upload dist/jdk4py-*.whl --username __token__ --password "$TWINE_PASSWORD"
 
-      - uses: conda-incubator/setup-miniconda@v2
-        with:
-          channels: conda-forge
-          conda-build-version: "3.21.5"
-
-      - name: Build Conda package
-        run: conda build --no-anaconda-upload --output-folder dist .
-
       - name: Upload Conda package
         env:
           JDK4PY_CONDA_CHANNEL_PASSWORD: ${{ secrets.CONDA_CHANNEL_PASSWORD }}


Test patch:
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 119185b..7f610d7 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -19,32 +19,10 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
-      - uses: actions/setup-python@v2
+      - uses: ./.github/actions/build-jdk
         with:
-          architecture: x64
           python-version: ${{ matrix.python }}
 
-      - name: Install Poetry
-        run: pip install poetry
-
-      - name: Install Python dependencies
-        run: poetry install
-
-      - name: Set environment variables
-        run: poetry run python scripts/set_environment.py
-
-      - uses: actions/setup-java@v2
-        with:
-          distribution: adopt
-          java-version: ${{ env.JDK4PY_JAVA_VERSION }}
-
-      - name: Build JDK
-        run: poetry run python scripts/build_jdk.py
-
-      - name: Build Python wheel
-        shell: bash
-        run: poetry run python setup.py bdist_wheel --build-number $JDK4PY_BUILD_NUMBER
-
       # No need to lint for each OS and Python version
       - if: matrix.os == 'ubuntu-latest' && matrix.python == '3.9'
         name: Check formatting
@@ -53,6 +31,8 @@ jobs:
       - name: Test
         run: poetry run pytest
 
+      - uses: ./.github/actions/create-python-wheel
+
       # No need to upload the package for each Python version
       - if: matrix.python == '3.9'
         uses: actions/upload-artifact@v2
@@ -67,35 +47,11 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
-      - uses: actions/setup-python@v2
+      - uses: ./.github/actions/build-jdk
         with:
-          architecture: x64
           python-version: "3.9"
 
-      - name: Install Poetry
-        run: pip install poetry
-
-      - name: Install Python dependencies
-        run: poetry install
-
-      - name: Set environment variables
-        run: poetry run python scripts/set_environment.py
-
-      - uses: actions/setup-java@v2
-        with:
-          distribution: adopt
-          java-version: ${{ env.JDK4PY_JAVA_VERSION }}
-
-      - name: Build JDK
-        run: poetry run python scripts/build_jdk.py
-
-      - uses: conda-incubator/setup-miniconda@v2
-        with:
-          channels: conda-forge
-          conda-build-version: "3.21.5"
-
-      - name: Build Conda package
-        run: conda build --no-anaconda-upload --output-folder dist .
+      - uses: ./.github/actions/create-conda-package
 
       - uses: actions/upload-artifact@v2
         with: