From f32c927889bebb51a5d0aa8757aeb568bbf38091 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 31 May 2020 16:34:05 -0400 Subject: [PATCH] version 0.2.2 --- .drone.yml | 56 +++++++++++++++++++++++++++++++-- CHANGELOG.md | 4 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++ VERSION | 2 +- src/cmd/release.rs | 2 ++ 7 files changed, 139 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 8426d98..8d29b1e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,5 +1,5 @@ kind: pipeline -name: tools +name: tests/release steps: - name: rust tests @@ -7,6 +7,9 @@ steps: pull: always commands: - cargo test + when: + event: + - push - name: auto-release image: xena/gitea-release:0.2.1 @@ -19,5 +22,52 @@ steps: event: - push branch: - include: - - master + - master + +--- + +kind: pipeline +name: docker +steps: + - name: build docker image + image: "monacoremo/nix:2020-04-05-05f09348-circleci" + environment: + USER: root + run: + - cachix use xe + - nix-build docker.nix + - cp $(readlink result) /result/docker.tgz + volumes: + - name: image + path: /result + when: + event: + - tag + + - name: push docker image + image: docker:dind + volumes: + - name: image + path: /result + - name: dockersock + path: /var/run/docker.sock + steps: + - docker load /result/docker.tgz + - echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + - docker push xena/gitea-release + environment: + DOCKER_USERNAME: + from_secret: DOCKER_USERNAME + DOCKER_PASSWORD: + from_secret: DOCKER_PASSWORD + when: + event: + - tag + +volumes: + - name: image + temp: {} + - name: dockersock + host: + path: /var/run/docker.sock + diff --git a/CHANGELOG.md b/CHANGELOG.md index fc77716..e35ae48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 0.2.2 + +Update README, automatically push docker images + ## 0.2.1 Hotfix for typos in the docker manifest. diff --git a/Cargo.lock b/Cargo.lock index 81e52c7..5a92fc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,7 +326,7 @@ dependencies = [ [[package]] name = "gitea-release" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "byte-unit", diff --git a/Cargo.toml b/Cargo.toml index 3af4488..d5b90d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitea-release" -version = "0.2.1" +version = "0.2.2" authors = ["Christine Dodrill "] edition = "2018" diff --git a/README.md b/README.md index bef1eb0..8b961bc 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,80 @@ repositories that reads from CHANGELOG and VERSION files. This is a clone of [github-release](https://github.com/github-release/github-release), but more suited for my individual needs. This may also turn into a generic webhook handler, but one thing at a time. :) + +## Installation + +### With Nix + +```console +$ nix-env -if https://tulpa.dev/cadey/gitea-release/archive/master.tar.gz +``` + +### With cargo + +```console +$ cargo install --git https://tulpa.dev/cadey/gitea-release.git +``` + +## Drone Plugin + +To use this as a drone plugin, add the following to your `.drone.yml`: + +```yaml +- name: auto-release + image: xena/gitea-release:0.2.2 + settings: + auth_username: cadey + changelog_path: ./CHANGELOG.md + gitea_server: https://tulpa.dev + gitea_token: + from_secret: GITEA_TOKEN + when: + event: + - push + branch: + - master +``` + +Replace the values of the settings as makes sense for your gitea server. The +`changelog_path` attribute is optional, and will be `./CHANGELOG.md` by default. + +## CHANGELOG.md and VERSION files + +The `CHANGELOG.md` file is based on the [Keep a Changelog][kacl] format, but +modified slightly to make it easier for this tool. Here is an example changelog +that this tool accepts: + +[kacl]: https://keepachangelog.com/en/1.0.0/ + +```markdown +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 0.1.0 + +Hi there this is a test! + +### ADDED + +- something +``` + +The `VERSION` file plays into this as well. The `VERSION` file MUST be a single +line containing a [semantic version][semver] string. When this tool is run with +the `release` subcommand, the following actions take place: + +[semver]: https://semver.org/spec/v2.0.0.html + +- The `VERSION` file is read and loaded as the desired tag for the repo +- The `CHANGELOG.md` file is read and the changes for the `VERSION` are + cherry-picked out of the file +- The git repo is checked to see if that tag already exists + - If the tag exists, the tool exits and does nothing +- If the tag does not exist, it is created (with the changelog fragment as the + body of the tag) and pushed to the gitea server +- A gitea release is created using the changelog fragment and the release name + is generated from the `VERSION` string diff --git a/VERSION b/VERSION index 0c62199..ee1372d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 diff --git a/src/cmd/release.rs b/src/cmd/release.rs index f2f9d6a..5a22c52 100644 --- a/src/cmd/release.rs +++ b/src/cmd/release.rs @@ -41,5 +41,7 @@ pub(crate) async fn run( return Err(anyhow!("{:?} -> {}", resp.status(), resp.text().await?)); } + println!("Created release {}", tag); + Ok(()) }