diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 636278c..a242a47 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,23 +1,23 @@ -name: Jenkiexs CD +name: Deploy Jenkiexs on: workflow_run: - workflows: ["Jenkiexs Master CI"] + workflows: ["Main CI"] types: - completed - jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -26,6 +26,7 @@ jobs: deps doc mix.exs + mix.lock key: ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | ${{ runner.os }}-mix-prod- @@ -50,16 +51,17 @@ jobs: run: mix docs check_package: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -68,6 +70,7 @@ jobs: deps doc mix.exs + mix.lock key: ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | ${{ runner.os }}-mix-prod- @@ -77,16 +80,17 @@ jobs: run: mix hex.publish --dry-run publish_package: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: check_package steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -95,6 +99,7 @@ jobs: deps doc mix.exs + mix.lock key: ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} restore-keys: | ${{ runner.os }}-mix-prod- @@ -105,18 +110,20 @@ jobs: update_version: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: publish_package - + permissions: + contents: write env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Update README.md and mix.exs run: | elixir ./scripts/update_version.exs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67edf1b..b6eff27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,23 @@ name: Jenkiexs CI -on: [ push, pull_request ] +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.9.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -37,16 +42,17 @@ jobs: run: mix compile lint: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.9.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -62,16 +68,17 @@ jobs: run: mix format --check-formatted test: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.9.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -85,21 +92,20 @@ jobs: - run: mix test coverage: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: test env: MIX_ENV: test GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.9.x' - otp-version: '22.3' - + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: diff --git a/.github/workflows/master-ci.yml b/.github/workflows/main-ci.yml similarity index 80% rename from .github/workflows/master-ci.yml rename to .github/workflows/main-ci.yml index 87d665f..bd465be 100644 --- a/.github/workflows/master-ci.yml +++ b/.github/workflows/main-ci.yml @@ -1,4 +1,4 @@ -name: Jenkiexs Master CI +name: Main CI on: push: @@ -7,15 +7,16 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -40,16 +41,17 @@ jobs: run: mix compile lint: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -65,16 +67,17 @@ jobs: run: mix format --check-formatted test: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.8.x' - otp-version: '22.3' + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -88,21 +91,20 @@ jobs: - run: mix test coverage: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: test env: MIX_ENV: test GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v3 - name: Set up Elixir uses: erlef/setup-beam@v1 with: - elixir-version: '1.9.x' - otp-version: '22.3' - + elixir-version: '1.8.2' + otp-version: '22.3.4.26' + version-type: 'strict' - name: Cache Dependencies uses: actions/cache@v2 with: @@ -124,9 +126,8 @@ jobs: trigger-cd: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: coverage - env: GITHUB_TOKEN: ${{ secrets.GITHUB_ACTIONS_USER }} steps: diff --git a/mix.exs b/mix.exs index 09e84c0..d0ccc7f 100644 --- a/mix.exs +++ b/mix.exs @@ -12,7 +12,7 @@ defmodule Jenkiexs.MixProject do version: @version, elixir: "~> 1.8", start_permanent: Mix.env() == :prod, - description: "Jenkins client written in Elixir", + description: "Jenkins API client written in Elixir", package: package(), deps: deps(), docs: docs(), diff --git a/scripts/update_version.exs b/scripts/update_version.exs index 0c93a8f..d9bb633 100644 --- a/scripts/update_version.exs +++ b/scripts/update_version.exs @@ -1,37 +1,22 @@ - -# {:ok, version} = File.read(version_file) -# version = String.trim(version) -# IO.puts("Updating to version #{version}") -# {:ok, mix_exs} = File.read(mix_exs_file) -# {:ok, readme} = File.read(readme_file) -# IO.puts("Updating #{mix_exs_file}...") -# mix_exs = String.replace(mix_exs, ~r/@version \".*\"/, "@version \"#{version}\"", global: false) -# mix_exs_file_update = File.write!(mix_exs_file, mix_exs) -# if mix_exs_file_update == :ok, -# do: IO.puts("#{mix_exs_file} updated successfully!"), -# else: raise "Could not update #{mix_exs_file} to version #{version}. #{inspect(mix_exs_file_update)}" -# -# IO.puts("Updating #{readme_file}...") -# readme = String.replace(readme, ~r/{:jenkiexs, \"~> .*\"}/, "{:jenkiexs, \"~> #{version}\"}") -# readme_file_update = File.write!(readme_file, readme) -# -# if readme_file_update == :ok, -# do: IO.puts("#{readme_file} updated successfully!"), -# else: raise "Could not update #{readme_file} to version #{version}. #{inspect(readme_file_update)}" - defmodule UpdateVersion do @version_file "./version" @mix_exs_file "./mix.exs" @readme_file "./README.md" + @mix_version_regex ~r/@version \"(?.*)\"/ + @readme_version_regex ~r/{:yamel, \"~> (?.*)\"}/ def update() do with {:ok, version} <- get_version(), {:ok, mix_exs} <- File.read(@mix_exs_file), {:ok, readme} <- File.read(@readme_file), + :new_version <- check_version(version, mix_exs, readme), {:ok, _mix_exs} <- update_mix(mix_exs, version), {:ok, _readme} <- update_readme(readme, version) do - IO.puts("\nThe application was updated to version #{version}!") + IO.puts("\nmix.exs and README.md successfully updated with version #{version}!") else + :same_version -> + IO.puts("mix.exs and README.md will not be changed") + {:error, reason} -> raise reason end @@ -42,9 +27,19 @@ defmodule UpdateVersion do {:ok, String.trim(version)} end + defp check_version(version, mix_exs, readme) do + with %{"version" => ^version} <- Regex.named_captures(@mix_version_regex, mix_exs), + %{"version" => ^version} <- Regex.named_captures(@readme_version_regex, readme) do + :same_version + else + _ -> + :new_version + end + end + def update_mix(mix_exs, version) do IO.puts("Updating #{@mix_exs_file}...") - mix_exs = String.replace(mix_exs, ~r/@version \".*\"/, "@version \"#{version}\"", global: false) + mix_exs = String.replace(mix_exs, @mix_version_regex, "@version \"#{version}\"", global: false) case File.write!(@mix_exs_file, mix_exs) do :ok -> @@ -56,7 +51,7 @@ defmodule UpdateVersion do def update_readme(readme, version) do IO.puts("Updating #{@readme_file}...") - readme = String.replace(readme, ~r/{:jenkiexs, \"~> .*\"}/, "{:jenkiexs, \"~> #{version}\"}") + readme = String.replace(readme, @readme_version_regex, "{:yamel, \"~> #{version}\"}") case File.write!(@readme_file, readme) do :ok -> diff --git a/version b/version index 7dea76e..524cb55 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.1 +1.1.1