feat(git_ops): Auto-releasing using git_ops.

This commit is contained in:
James Harton 2020-12-21 12:16:04 +13:00
parent 84d97265a1
commit 409e13e783
6 changed files with 172 additions and 21 deletions

View file

@ -1,49 +1,93 @@
image: elixir:latest
cache:
stages:
- build
- test
- version
- 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"
build:
image: elixir:latest
stage: build
cache:
key: "$CI_JOB_NAME"
paths:
- deps
- _build
- /root/.mix
variables:
MIX_ENV: "test"
before_script:
- .hex
- .mix
script:
- mix local.hex --force
- mix local.rebar --force
- mix deps.get --only test
- mix deps.get
- mix deps.compile
artifacts:
paths:
- _build/
- deps/
- .hex
- .mix
test:
image: elixir:latest
needs:
- job: build
artifacts: true
stage: test
script:
- mix test
integrate:
image: elixir:latest
needs:
- job: build
artifacts: true
stage: test
tags:
- sense-hat
script:
- mix clean
- SENSE_HAT_PRESENT=true mix test
credo:
image: elixir:latest
needs:
- job: build
artifacts: true
stage: test
script:
- mix credo
audit:
image: elixir:latest
needs:
- job: build
artifacts: true
stage: test
script:
- mix hex.audit
format:
image: elixir:latest
needs:
- job: build
artifacts: true
stage: test
script:
- mix format --check-formatted
pages:
stage: deploy
image: elixir:latest
needs:
- job: build
artifacts: true
stage: release
script:
- mix docs -o public
artifacts:
@ -52,12 +96,66 @@ pages:
only:
- master
package:
stage: deploy
git_ops:
image: elixir:latest
needs:
- job: build
artifacts: true
- job: audit
- job: credo
- job: format
- job: test
stage: version
only:
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
refs:
- master
except:
variables:
- $CI_COMMIT_MESSAGE =~ /chore\:\ release version/
script:
- mix hex.build
- |
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
mix git_ops.project_info -f shell > artifacts/env
source artifacts/env
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}"
artifacts:
paths:
- "wafer-*.tar"
- artifacts/*
release-gitlab:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
only:
- master
needs:
- job: git_ops
artifacts: true
script:
- |
source artifacts/env
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
needs:
- job: build
artifacts: true
- job: git_ops
stage: release
only:
- master
script:
- mix hex.publish --yes

41
CHANGELOG.md Normal file
View file

@ -0,0 +1,41 @@
# 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.6](https://gitlab.com/jimsy/wafer/compare/v0.1.5...v0.1.6) (2020-12-26)
## [v0.1.5](https://gitlab.com/jimsy/wafer/compare/v0.1.4...v0.1.5) (2020-12-26)
## [v0.1.4](https://gitlab.com/jimsy/wafer/compare/v0.1.3...v0.1.4) (2020-12-26)
## [v0.1.3](https://gitlab.com/jimsy/wafer/compare/v0.1.2...v0.1.3) (2020-12-26)
## [v0.1.2](https://gitlab.com/jimsy/wafer/compare/v0.1.1...v0.1.2) (2020-12-26)
## [v0.1.1](https://gitlab.com/jimsy/wafer/compare/v0.1.0...v0.1.1) (2020-12-26)
## [v0.1.0](https://gitlab.com/jimsy/wafer/compare/v0.1.0...v0.1.0) (2020-12-20)

View file

@ -122,7 +122,7 @@ by adding `wafer` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:wafer, "~> 0.1"}
{:wafer, "~> 0.1.6"}
]
end
```

View file

@ -1,3 +1,11 @@
use Mix.Config
config :wafer, Wafer.Driver.Fake, warn: Mix.env() != :test
config :git_ops,
mix_project: Mix.Project.get!(),
changelog_file: "CHANGELOG.md",
repository_url: "https://gitlab.com/jimsy/wafer",
manage_mix_version?: true,
manage_readme_version: "README.md",
version_tag_prefix: "v"

10
mix.exs
View file

@ -6,7 +6,8 @@ defmodule Wafer.MixProject do
Wafer is an Elixir library to make writing drivers for i2c and SPI connected
peripherals and interacting with GPIO pins easier.
"""
@version "0.1.0"
@version "0.1.6"
def project do
[
@ -45,10 +46,11 @@ defmodule Wafer.MixProject do
{:circuits_gpio, "~> 0.4", optional: true},
{:circuits_i2c, "~> 0.3", optional: true},
{:circuits_spi, "~> 0.1", optional: true},
{:credo, "~> 1.1", only: [:dev, :test], runtime: false},
{:earmark, ">= 0.0.0", only: [:dev, :test]},
{:credo, "~> 1.1", only: ~w[dev test]a, runtime: false},
{:earmark, ">= 0.0.0", only: ~w[dev test]a},
{:elixir_ale, "~> 1.2", optional: true},
{:ex_doc, ">= 0.0.0", only: [:dev, :test]},
{:ex_doc, ">= 0.0.0", only: ~w[dev test]a},
{:git_ops, "~> 2.2", only: ~w[dev test]a, runtime: false},
{:mimic, "~> 1.1", only: :test}
]
end

View file

@ -10,6 +10,8 @@
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"},
"git_ops": {:hex, :git_ops, "2.2.0", "27a2e38cf5d71ebdd287c90006c0a41dee8b2309369f8a97d3f6e3a2c279fe2f", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "6fa296bb9c2d737efba7ef52f3e6cdfafeb6a599db97f65c29b56e09f29b67e0"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"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.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"},