pact_broker-client 1.28.1 → 1.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0594e8363c37a845751df4f6d43a6a91fc7f54ac82de0bcea21b83ec02537a0
4
- data.tar.gz: 34106b65fa2e619195881b2e64de303fb010a68979ee5a95ba47aa34b2e76690
3
+ metadata.gz: 75733826388c0e949cc668a58d42f2020383afab1a5434f0357a3f8e4b807042
4
+ data.tar.gz: 536c574d886e62b61b76ec9d6e19c20719fb61facf5d75537cf882841515c364
5
5
  SHA512:
6
- metadata.gz: 40fe92403a62268fd688e6d0a6f47e237bcc946e345f99bafc31adc803905a7859af00241b3f9293f898e548d6e0aadd80767de8fb14952d5442a05e9cb80326
7
- data.tar.gz: 3fe4645ba758d96a53c6f1dbc0a0faf1129ca8e7ef6e3c62f8be2c677e43bc139071835491d17040a9e47312f3cc2b49a7ad0454d1de14f8ae245719db1a3d1b
6
+ metadata.gz: 96ddbb368e99906b3a7b8d69d118283edfad013e8ed605af7430cca7babcbfe0f10bb1ffd43b7dec98cbe134368d48f811b04454aa60baa431eb81ac4b2856bb
7
+ data.tar.gz: 971e100f31ec4a5ea338e60d6f6e0f13f924430f98b40d637e23d2d80be39c243ac4ea0cd9905515563de486d3cb35b7e79993a92fea0884f499e987381d55b3
@@ -3,23 +3,41 @@ name: Release gem
3
3
  on:
4
4
  repository_dispatch:
5
5
  types:
6
- - release
6
+ - release-triggered
7
7
 
8
8
  jobs:
9
- build:
9
+ release:
10
10
  runs-on: ubuntu-latest
11
+ outputs:
12
+ gem_name: ${{ steps.release.outputs.gem_name }}
13
+ version: ${{ steps.release.outputs.version }}
14
+ increment: ${{ steps.release.outputs.increment }}
11
15
  steps:
12
16
  - uses: actions/checkout@v2
13
17
  with:
14
18
  fetch-depth: 0
15
- - uses: pact-foundation/release-gem@v0.0.5
19
+ - uses: pact-foundation/release-gem@v0.0.10
20
+ id: release
16
21
  env:
17
22
  GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'
18
23
  GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
19
24
  INCREMENT: '${{ github.event.client_payload.increment }}'
20
- - name: Trigger release of pact-cli Docker image
21
- uses: peter-evans/repository-dispatch@v1
22
- with:
23
- token: ${{ secrets.GHTOKENFORPACTCLIRELEASE }}
24
- repository: pact-foundation/pact-ruby-cli
25
- event-type: gem-released
25
+ dispatch:
26
+ needs: release
27
+ strategy:
28
+ matrix:
29
+ repository: [pact-foundation/pact-ruby-cli, pact-foundation/pact-ruby-standalone]
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Notify ${{ matrix.repository }} of gem release
33
+ uses: peter-evans/repository-dispatch@v1
34
+ with:
35
+ token: ${{ secrets.GHTOKENFORPACTCLIRELEASE }}
36
+ repository: ${{ matrix.repository }}
37
+ event-type: gem-released
38
+ client-payload: |
39
+ {
40
+ "name": "${{ needs.release.outputs.gem_name }}",
41
+ "version": "${{ needs.release.outputs.version }}",
42
+ "increment": "${{ needs.release.outputs.increment }}"
43
+ }
@@ -1,3 +1,13 @@
1
+ <a name="v1.28.2"></a>
2
+ ### v1.28.2 (2020-07-17)
3
+
4
+
5
+ #### Bug Fixes
6
+
7
+ * **create-version-tag**
8
+ * raise an error if the version does not exist rather than automatically creating it. ([2ed7a55](/../../commit/2ed7a55))
9
+
10
+
1
11
  <a name="v1.28.0"></a>
2
12
  ### v1.28.0 (2020-07-12)
3
13
 
data/README.md CHANGED
@@ -42,13 +42,11 @@ Publish pacts to a Pact Broker.
42
42
  ### create-version-tag
43
43
 
44
44
  ```
45
- Usage:
46
- pact-broker create-version-tag -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION
47
-
48
45
  Options:
49
46
  -a, --pacticipant=PACTICIPANT # The pacticipant name
50
47
  -e, --version=VERSION # The pacticipant version
51
48
  -t, [--tag=TAG] # Tag name for pacticipant version. Can be specified multiple times.
49
+ [--auto-create-version], [--no-auto-create-version] # Automatically create the pacticipant version if it does not exist. Default: false
52
50
  -g, [--tag-with-git-branch], [--no-tag-with-git-branch] # Tag pacticipant version with the name of the current git branch. Default: false
53
51
  -b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker
54
52
  -u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
@@ -8,6 +8,7 @@ module PactBroker
8
8
  class PactPublicationError < ::Thor::Error; end
9
9
  class WebhookCreationError < ::Thor::Error; end
10
10
  class AuthError < ::Thor::Error; end
11
+ class VersionCreationError < ::Thor::Error; end
11
12
 
12
13
  class Broker < CustomThor
13
14
  desc 'can-i-deploy', ''
@@ -64,6 +65,7 @@ module PactBroker
64
65
  method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name"
65
66
  method_option :version, required: true, aliases: "-e", desc: "The pacticipant version"
66
67
  method_option :tag, aliases: "-t", type: :array, banner: "TAG", desc: "Tag name for pacticipant version. Can be specified multiple times."
68
+ method_option :auto_create_version, type: :boolean, default: false, desc: "Automatically create the pacticipant version if it does not exist. Default: false"
67
69
  method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag pacticipant version with the name of the current git branch. Default: false"
68
70
  method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
69
71
  method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
@@ -80,7 +82,10 @@ module PactBroker
80
82
  options.pacticipant,
81
83
  options.version,
82
84
  tags,
85
+ options.auto_create_version,
83
86
  pact_broker_client_options)
87
+ rescue PactBroker::Client::Error => e
88
+ raise VersionCreationError.new(e.message)
84
89
  end
85
90
 
86
91
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that the version belongs to."
@@ -6,30 +6,22 @@ module PactBroker
6
6
  module Client
7
7
  class CreateTag
8
8
 
9
- class Result
10
- attr_reader :success, :message
11
-
12
- def initialize success, message = nil
13
- @success = success
14
- @message = message
15
- end
16
- end
17
-
18
- def self.call(pact_broker_base_url, pacticipant_name, version, tags, pact_broker_client_options={})
19
- new(pact_broker_base_url, pacticipant_name, version, tags, pact_broker_client_options).call
9
+ def self.call(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options={})
10
+ new(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options).call
20
11
  end
21
12
 
22
- def initialize(pact_broker_base_url, pacticipant_name, version, tags, pact_broker_client_options)
13
+ def initialize(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options)
23
14
  @pact_broker_base_url = pact_broker_base_url
24
15
  @pacticipant_name = pacticipant_name
25
16
  @version = version
26
17
  @tags = tags
18
+ @auto_create_version = auto_create_version
27
19
  @pact_broker_client_options = pact_broker_client_options
28
20
  end
29
21
 
30
22
  def call
23
+ ensure_version_exists if !auto_create_version
31
24
  tags.each do | tag |
32
- # todo check that pacticipant exists first
33
25
  $stdout.puts "Tagging #{pacticipant_name} version #{version} as #{tag}"
34
26
  Retry.while_error do
35
27
  pact_broker_client.pacticipants.versions.tag pacticipant: pacticipant_name, version: version, tag: tag
@@ -39,11 +31,17 @@ module PactBroker
39
31
 
40
32
  private
41
33
 
42
- attr_reader :pact_broker_base_url, :pacticipant_name, :version, :tags, :pact_broker_client_options
34
+ attr_reader :pact_broker_base_url, :pacticipant_name, :version, :tags, :auto_create_version, :pact_broker_client_options
43
35
 
44
36
  def pact_broker_client
45
37
  @pact_broker_client ||= PactBroker::Client::PactBrokerClient.new(base_url: pact_broker_base_url, client_options: pact_broker_client_options)
46
38
  end
39
+
40
+ def ensure_version_exists
41
+ if pact_broker_client.pacticipants.versions.find(pacticipant: pacticipant_name, version: version).nil?
42
+ raise PactBroker::Client::Error.new("Could not create tag. Version #{version} of #{pacticipant_name} does not exist.")
43
+ end
44
+ end
47
45
  end
48
46
  end
49
47
  end
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.28.1'
3
+ VERSION = '1.28.2'
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ module PactBroker
28
28
 
29
29
  def call
30
30
  version_hash = if params[:version]
31
- versions_client.find params
31
+ versions_client.find(params)
32
32
  else
33
33
  pact_broker_client.pacticipants.versions.latest(params)
34
34
  end
@@ -1,14 +1,30 @@
1
- #!/bin/bash
1
+ #!/bin/sh
2
2
 
3
- output=$(curl -v -X POST https://api.github.com/repos/pact-foundation/pact_broker-client/dispatches \
3
+ # Script to trigger release of gem via the pact-foundation/release-gem action
4
+ # Requires a Github API token with repo scope stored in the
5
+ # environment variable GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES
6
+
7
+ : "${GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES:?Please set environment variable GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES}"
8
+
9
+ if [ -n "$1" ]; then
10
+ increment="\"${1}\""
11
+ else
12
+ increment="null"
13
+ fi
14
+
15
+ repository_slug=$(git remote get-url $(git remote show) | cut -d':' -f2 | sed 's/\.git//')
16
+
17
+ output=$(curl -v -X POST https://api.github.com/repos/${repository_slug}/dispatches \
4
18
  -H 'Accept: application/vnd.github.everest-preview+json' \
5
- -H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" \
6
- -d '{"event_type": "release-patch"}' 2>&1)
19
+ -H "Authorization: Bearer $GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES" \
20
+ -d "{\"event_type\": \"release-triggered\", \"client_payload\": {\"increment\": ${increment}}}" 2>&1)
7
21
 
8
22
  if ! echo "${output}" | grep "HTTP\/1.1 204" > /dev/null; then
9
- echo "$output" | sed "s/${GITHUB_ACCESS_TOKEN}/****/g"
10
- echo "Failed to do the thing"
23
+ echo "$output" | sed "s/${GITHUB_ACCESS_TOKEN_FOR_PF_RELEASES}/********/g"
24
+ echo "Failed to trigger release"
11
25
  exit 1
26
+ else
27
+ echo "Release workflow triggered"
12
28
  fi
13
29
 
14
- echo "See https://github.com/pact-foundation/pact_broker-client/actions?query=workflow%3A%22Release+gem%22"
30
+ echo "See https://github.com/${repository_slug}/actions?query=workflow%3A%22Release+gem%22"
@@ -5,7 +5,7 @@ describe "pact-broker create-version-tag", skip_windows: true do
5
5
  end
6
6
 
7
7
  context "when the version is successfully tagged" do
8
- subject { `bundle exec bin/pact-broker create-version-tag --pacticipant Condor --version 1.3.0 --tag prod --broker-base-url http://localhost:5001` }
8
+ subject { `bundle exec bin/pact-broker create-version-tag --auto-create-version --pacticipant Condor --version 1.3.0 --tag prod --broker-base-url http://localhost:5001` }
9
9
 
10
10
  it "returns a success exit code" do
11
11
  subject
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.28.1
4
+ version: 1.28.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -218,7 +218,6 @@ files:
218
218
  - pact-broker-client.gemspec
219
219
  - script/generate-cli-usage.sh
220
220
  - script/publish-pact.sh
221
- - script/release-via-github-action.sh
222
221
  - script/release.sh
223
222
  - script/trigger-release.sh
224
223
  - spec/integration/can_i_deploy_spec.rb
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
- set +e
3
-
4
- git tag -d release
5
- git push --delete origin release
6
- git tag -a release -m "chore: releasing"
7
- git push origin release