chore: set up git_ops and auto-releasing
This commit is contained in:
parent
d145a1af75
commit
d40df89261
5 changed files with 128 additions and 22 deletions
119
.gitlab-ci.yml
119
.gitlab-ci.yml
|
@ -1,42 +1,76 @@
|
|||
image: elixir:latest
|
||||
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
paths:
|
||||
- deps
|
||||
- _build
|
||||
- /root/.mix
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- release
|
||||
|
||||
variables:
|
||||
MIX_ENV: "test"
|
||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/"
|
||||
HEX_HOME: "$CI_PROJECT_DIR/.hex"
|
||||
MIX_HOME: "$CI_PROJECT_DIR/.mix"
|
||||
|
||||
before_script:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix deps.get --only test
|
||||
build:
|
||||
image: elixir:latest
|
||||
stage: build
|
||||
cache:
|
||||
key: "$CI_JOB_NAME"
|
||||
paths:
|
||||
- deps
|
||||
- _build
|
||||
- .hex
|
||||
- .mix
|
||||
script:
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
- mix deps.get
|
||||
- mix deps.compile
|
||||
- mix git_ops.project_info -f dotenv > project_info.env
|
||||
artifacts:
|
||||
paths:
|
||||
- _build/
|
||||
- deps/
|
||||
- .hex
|
||||
- .mix
|
||||
reports:
|
||||
dotenv: project_info.env
|
||||
|
||||
test:
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: test
|
||||
script:
|
||||
- mix test
|
||||
|
||||
credo:
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: test
|
||||
script:
|
||||
- mix credo
|
||||
|
||||
audit:
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: test
|
||||
script:
|
||||
- mix hex.audit
|
||||
|
||||
format:
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: test
|
||||
script:
|
||||
- mix format --check-formatted
|
||||
|
||||
pages:
|
||||
stage: deploy
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: release
|
||||
script:
|
||||
- mix docs -o public
|
||||
artifacts:
|
||||
|
@ -45,12 +79,61 @@ pages:
|
|||
only:
|
||||
- main
|
||||
|
||||
package:
|
||||
stage: deploy
|
||||
git_ops:
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: release
|
||||
only:
|
||||
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
|
||||
refs:
|
||||
- main
|
||||
except:
|
||||
variables:
|
||||
- $CI_COMMIT_MESSAGE =~ /chore\:\ release version/
|
||||
script:
|
||||
- mix hex.build
|
||||
- |
|
||||
export OLD_APP_VERSION=$APP_VERSION
|
||||
mkdir -p artifacts
|
||||
git config --global user.name "Gitlab Runner for ${GITLAB_USER_NAME}"
|
||||
git config --global user.email "${GITLAB_USER_EMAIL}"
|
||||
mix git_ops.release --yes || true
|
||||
mix git_ops.project_info -f shell > artifacts/env
|
||||
source artifacts/env
|
||||
if [ "v${OLD_APP_VERSION}" != "v${APP_VERSION}" ]; then
|
||||
mix hex.build -o "artifacts/${APP_NAME}-${APP_VERSION}.tar"
|
||||
gzip "artifacts/${APP_NAME}-${APP_VERSION}.tar"
|
||||
mix docs && tar zcvf "artifacts/${APP_NAME}-${APP_VERSION}-docs.tar.gz" doc/
|
||||
curl --header "JOB_TOKEN: ${CI_JOB_TOKEN}" --upload-file "artifacts/${APP_NAME}-${APP_VERSION}.tar.gz" "${PACKAGE_REGISTRY_URL}/${APP_NAME}/${APP_VERSION}/${APP_NAME}-${APP_VERSION}.tar.gz"
|
||||
curl --header "JOB_TOKEN: ${CI_JOB_TOKEN}" --upload-file "artifacts/${APP_NAME}-${APP_VERSION}-docs.tar.gz" "${PACKAGE_REGISTRY_URL}/${APP_NAME}/${APP_VERSION}/${APP_NAME}-${APP_VERSION}-docs.tar.gz"
|
||||
git push "https://project_${CI_PROJECT_ID}_bot:${RELEASE_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git" "HEAD:${CI_COMMIT_REF_NAME}" "refs/tags/v${APP_VERSION}"
|
||||
fi
|
||||
artifacts:
|
||||
paths:
|
||||
- "circuits_uart_midi_framing-*.tar"
|
||||
- artifacts/*
|
||||
|
||||
release-gitlab:
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: release
|
||||
only:
|
||||
- tags
|
||||
- /^v\d+\.\d+\.\d+(-\w+)?$/
|
||||
script:
|
||||
- release-cli create \
|
||||
--name "Release ${APP_NAME} ${APP_VERSION}" \
|
||||
--description "./CHANGELOG.md" \
|
||||
--tag-name "v${APP_VERSION}" \
|
||||
--assets-link "{\"name\":\"${APP_NAME}-${APP_VERSION}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_NAME}/${APP_VERSION}/${APP_NAME}-${APP_VERSION}.tar.gz\"}" \
|
||||
--assets-link "{\"name\":\"${APP_NAME}-${APP_VERSION}-docs.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_NAME}/${APP_VERSION}/${APP_NAME}-${APP_VERSION}-docs.tar.gz\"}"
|
||||
|
||||
release-hex:
|
||||
image: elixir:latest
|
||||
dependencies:
|
||||
- build
|
||||
stage: release
|
||||
only:
|
||||
- tags
|
||||
- /^v\d+\.\d+\.\d+(-\w+)?$/
|
||||
script:
|
||||
- mix hex.publish --yes
|
||||
|
|
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](Https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v0.1.0](https://gitlab.com/jimsy/circuits_uart_midi_framing/compare/v0.1.0...v0.1.0) (2021-12-08)
|
||||
|
||||
|
||||
|
9
config/config.exs
Normal file
9
config/config.exs
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Config
|
||||
|
||||
config :git_ops,
|
||||
mix_project: Mix.Project.get!(),
|
||||
changelog_file: "CHANGELOG.md",
|
||||
repository_url: "https://gitlab.com/jimsy/circuits_uart_midi_framing",
|
||||
manage_mix_version?: true,
|
||||
manage_readme_version: "README.md",
|
||||
version_tag_prefix: "v"
|
5
mix.exs
5
mix.exs
|
@ -21,7 +21,7 @@ defmodule Circuits.UART.Framing.MIDI.MixProject do
|
|||
|
||||
def package do
|
||||
[
|
||||
maintainers: ["James Harton <james@automat.nz>"],
|
||||
maintainers: ["James Harton <james@harton.nz>"],
|
||||
licenses: ["Hippocratic"],
|
||||
links: %{
|
||||
"Source" => "https://gitlab.com/jimsy/circuits_uart_midi_framing"
|
||||
|
@ -42,7 +42,8 @@ defmodule Circuits.UART.Framing.MIDI.MixProject do
|
|||
{:circuits_uart, "~> 1.4"},
|
||||
{:credo, "~> 1.1", only: [:dev, :test], runtime: false},
|
||||
{:earmark, ">= 0.0.0", only: [:dev, :test]},
|
||||
{:ex_doc, ">= 0.0.0", only: [:dev, :test]}
|
||||
{:ex_doc, ">= 0.0.0", only: [:dev, :test]},
|
||||
{:git_ops, "~> 2.3", only: ~w[dev test]a, runtime: false},
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
6
mix.lock
6
mix.lock
|
@ -5,8 +5,10 @@
|
|||
"earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"},
|
||||
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
|
||||
"ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"},
|
||||
"git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"},
|
||||
"git_ops": {:hex, :git_ops, "2.4.5", "185a724dfde3745edd22f7571d59c47a835cf54ded67e9ccbc951920b7eec4c2", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e323a5b01ad53bc8c19c3a444be3e61ed7803ecd2e95530446ae9327d0143ecc"},
|
||||
"jason": {:hex, :jason, "1.2.0", "10043418c42d2493d0ee212d3fddd25d7ffe484380afad769a0a38795938e448", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "116747dbe057794c3a3e4e143b7c8390b29f634e16c78a7f59ba75bfa6852e7f"},
|
||||
"makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49736fe5b66a08d8575bf5321d716bac5da20c8e6b97714fec2bcd6febcfa1f8"},
|
||||
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
|
||||
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"},
|
||||
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"},
|
||||
"nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue