From 4dd12021953b125ad70346d221e091eae6e819f1 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 12 Jun 2020 08:17:04 -0400 Subject: [PATCH] Automatically pull tags on Drone Closes #4 --- CHANGELOG.md | 4 ++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 16 ++-------------- VERSION | 2 +- src/cmd/drone_plugin.rs | 4 +++- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e49181..8cf9bff 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.3.2 + +Automagically fetch tags when running as a drone plugin. + ## 0.3.1 Hotfix in json parsing diff --git a/Cargo.lock b/Cargo.lock index 2ab47ee..351c247 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,7 +326,7 @@ dependencies = [ [[package]] name = "gitea-release" -version = "0.3.1" +version = "0.3.2" dependencies = [ "anyhow", "byte-unit", diff --git a/Cargo.toml b/Cargo.toml index 28658d5..f8c9744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitea-release" -version = "0.3.1" +version = "0.3.2" authors = ["Christine Dodrill "] edition = "2018" diff --git a/README.md b/README.md index b709c36..681c5ee 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ To use this as a drone plugin, add the following to your `.drone.yml` under the ```yaml - name: auto-release - image: xena/gitea-release:0.3.1 + image: xena/gitea-release:0.3.2 settings: auth_username: cadey changelog_path: ./CHANGELOG.md @@ -47,25 +47,13 @@ To use this as a drone plugin, add the following to your `.drone.yml` under the 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. -Note that Drone doesn't clone git tags by default. You will need to add a -tag-fetching step to your Drone config until -[#4](https://tulpa.dev/cadey/gitea-release/issues/4) is fixed. You can do that -by adding this before your auto-release step: - -``` - - name: fetch tags - image: alpine/git - commands: - - git fetch --tags -``` - The default branch will automatically be derived from the Gitea API. If you need to hard-code your default branch name for some reason, add the `default_branch` setting like this: ```yaml - name: auto-release - image: xena/gitea-release:0.3.1 + image: xena/gitea-release:0.3.2 settings: auth_username: cadey default_branch: trunk diff --git a/VERSION b/VERSION index 9e11b32..d15723f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.1 +0.3.2 diff --git a/src/cmd/drone_plugin.rs b/src/cmd/drone_plugin.rs index f799941..71b2152 100644 --- a/src/cmd/drone_plugin.rs +++ b/src/cmd/drone_plugin.rs @@ -25,7 +25,9 @@ pub(crate) async fn run(env: DroneEnv) -> Result<()> { u.set_username(&env.auth_user).unwrap(); u.set_password(Some(&env.token)).unwrap(); repo.remote_delete("origin")?; - repo.remote("origin", u.as_str())?; + let mut origin = repo.remote("origin", u.as_str())?; + origin.connect(git2::Direction::Fetch)?; + origin.fetch(&["refs/tags/*:refs/tags/*"], None, None)?; release::run( common,