Skip to content

Commit

Permalink
Merge pull request #2088 from shaangill025/issue_cred_2.1
Browse files Browse the repository at this point in the history
Feat: Multiple Credential Issuance [v2.1]
  • Loading branch information
ianco authored Feb 13, 2023
2 parents 3c3a668 + 9c4f940 commit 725faf7
Show file tree
Hide file tree
Showing 35 changed files with 4,767 additions and 672 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-indy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish ACA-Py Image (Indy)
run-name: Publish ACA-Py ${{ inputs.tag || github.event.release.tag_name }} Image (Indy ${{ inputs.indy_version || '1.16.0' }})
on:
release:
types: [released]
types: [published]

workflow_dispatch:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish ACA-Py Image
run-name: Publish ACA-Py ${{ inputs.tag || github.event.release.tag_name }} Image
on:
release:
types: [released]
types: [published]

workflow_dispatch:
inputs:
Expand Down
271 changes: 183 additions & 88 deletions CHANGELOG.md

Large diffs are not rendered by default.

115 changes: 104 additions & 11 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,116 @@ Once ready to do a release, create a local branch that includes the following up

3. Include details of the merged PRs included in this release. General process to follow:

- Gather the set of PRs since the last release and put them into a list. A good tool to use for this is the [github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator). Steps:
- Create a read only GitHub token for your account on this page: [https://github.com/settings/tokens](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token) with a scope of `repo` / `public_repo`.
- Use a command like the following, adjusting the tag parameters as appropriate. `docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator --user hyperledger --project aries-cloudagent-python --output 0.7.4-rc0.md --since-tag 0.7.3 --future-release 0.7.4-rc0 --release-branch main --token <your-token>`
- In the generated file, use only the PR list -- we don't include the list of closed issues in the Change Log.
- Gather the set of PRs since the last release and put them into a list. A good
tool to use for this is the
[github-changelog-generator](https://github.com/github-changelog-generator/github-changelog-generator).
Steps:
- Create a read only GitHub token for your account on this page:
[https://github.com/settings/tokens](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token)
with a scope of `repo` / `public_repo`.
- Use a command like the following, adjusting the tag parameters as
appropriate. `docker run -it --rm -v "$(pwd)":/usr/local/src/your-app
githubchangeloggenerator/github-changelog-generator --user hyperledger
--project aries-cloudagent-python --output 0.7.4-rc0.md --since-tag 0.7.3
--future-release 0.7.4-rc0 --release-branch main --token <your-token>`
- In the generated file, use only the PR list -- we don't include the list of
closed issues in the Change Log.

In some cases, the approach above fails because of too many API calls. An
alternate approach to getting the list of PRs in the right format is to use this
scary `sed` pipeline process to get the same output.¥

- Put the following commands into a file called `changelog.sed`

``` bash
/Approved/d
/updated /d
/^$/d
/^ [0-9]/d
s/was merged.*//
/^@/d
s# by \(.*\) # [\1](https://github.com/\1)#
s/^ //
s# \#\([0-9]*\)# [\#\1](https://github.com/hyperledger/aries-cloudagent-python/pull/\1) #
s/ / /g
/^Version/d
/tasks done/d
s/^/- /
```

- Navigate in your browser to the paged list of PRs merged since the last
release (using in the GitHub UI a filter such as `is:pr is:merged sort:updated
merged:>2022-04-07`) and for each page, highlight, and copy the text
of only the list of PRs on the page to use in the following step.
- For each page, run the command `sed -e :a -e '$!N;s/\n#/ #/;ta' -e 'P;D' <<EOF
| sed -f changelog.sed`, paste in the copied text and then type `EOF`.
Redirect the output to a file, appending each page of output to the file.
- The first `sed` command in the pipeline merges the PR title and PR number
plus author lines onto a single line. The commands in the `changelog.sed`
file just clean up the data, removing unwanted lines, etc.
- At the end of that process, you should have a list of all of the PRs in a form you can
use in the CHANGELOG.md file.
- To verify you have right contents, you can do a `wc` of the file and there
should be one line per PR. You should scan the file as well, looking for
anomalies. It's a pretty ugly process.
- Using a `curl` command and the GitHub API is probably a much better and more
robust way to do this, but this was quick and dirty...

Once you have the list of PRs:

- Organize the list into suitable categories, update (if necessary) the PR description and add notes to clarify the changes. See previous release entries to understand the style -- a format should help developers.
- Add a narrative about the release above the PR that highlights what has gone into the release.

4. Update the ReadTheDocs in the `/docs` folder by following the instructions in the `docs/README.md` file. That will likely add a number of new and modified files to the PR. Eliminate all of the errors in the generation process, either by mocking external dependencies or by fixing ACA-Py code. If necessary, create an issue with the errors and assign it to the appropriate developer. Experience has demonstrated to use that documentation generation errors should be fixed in the code.
4. Update the ReadTheDocs in the `/docs` folder by following the instructions in
the `docs/README.md` file. That will likely add a number of new and modified
files to the PR. Eliminate all of the errors in the generation process,
either by mocking external dependencies or by fixing ACA-Py code. If
necessary, create an issue with the errors and assign it to the appropriate
developer. Experience has demonstrated to use that documentation generation
errors should be fixed in the code.

5. Update the version number listed in [aries_cloudagent/version.py](aries_cloudagent/version.py) and, prefixed with a "v" in [open-api/openapi.json](open-api/openapi.json) (e.g. "0.7.2" in the version.py file and "v0.7.2" in the openapi.json file). The incremented version number should adhere to the [Semantic Versioning Specification](https://semver.org/#semantic-versioning-specification-semver) based on the changes since the last published release. For Release Candidates, the form of the tag is "0.7.2-rc0".
5. Update the version number listed in
[aries_cloudagent/version.py](aries_cloudagent/version.py) and, prefixed with
a "v" in [open-api/openapi.json](open-api/openapi.json) (e.g. "0.7.2" in the
version.py file and "v0.7.2" in the openapi.json file). The incremented
version number should adhere to the [Semantic Versioning
Specification](https://semver.org/#semantic-versioning-specification-semver)
based on the changes since the last published release. For Release
Candidates, the form of the tag is "0.7.2-rc0".

6. An extra search of the repo for the existing tag is recommended to see if there are any other instances of the tag in the repo. If any are found to be required (other than in CHANGELOG.md and the examples in this file, of course), finding a way to not need them is best, but if they are needed, please update this document to note where the tag can be found.
6. An extra search of the repo for the existing tag is recommended to see if
there are any other instances of the tag in the repo. If any are found to be
required (other than in CHANGELOG.md and the examples in this file, of
course), finding a way to not need them is best, but if they are needed,
please update this document to note where the tag can be found.

7. Double check all of these steps above, and then submit a PR from the branch.
If there are still further changes to be merged, mark the PR as "Draft",
repeat **ALL** of the steps again, and then mark this PR as ready and then
wait until it is merged.

8. Immediately after it is merged, create a new GitHub tag representing the
version. The tag name and title of the release should be the same as the
version in [aries_cloudagent/version.py](aries_cloudagent/version.py). Use
the "Generate Release Notes" capability to get a sequential listing of the
PRs in the release, to complement the manually curated Changelog. Verify on
PyPi that the version is published.

7. Double check all of these steps above, and then submit a PR from the branch. If there are still further changes to be merged, mark the PR as "Draft", repeat **ALL** of the steps again, and then mark this PR as ready and then wait until it is merged.
9. New images for the release are automatically published by the GitHubAction
Workflows: [publish.yml] and [publish-indy.yml]. The actions are triggered
when a release is tagged, so no manual action is needed. The images are
published in the [Hyperledger Package Repository under
aries-cloudagent-python](https://github.com/orgs/hyperledger/packages?repo_name=aries-cloudagent-python)
and a link to the packages added to the repositories main page (under
"Packages").

8. Immediately after it is merged, create a new GitHub tag representing the version. The tag name and title of the release should be the same as the version in [aries_cloudagent/version.py](aries_cloudagent/version.py). Use the "Generate Release Notes" capability to get a sequential listing of the PRs in the release, to complement the manually curated Changelog. Verify on PyPi that the version is published.
Additional information about the container image publication process can be
found in the document [Container Images and Github Actions]().

9. Publish a new docker container on Docker Hub ([bcgovimages/aries-cloudagent](https://hub.docker.com/r/bcgovimages/aries-cloudagent/)) by following the README.md instructions to create a PR for the release in the repository [https://github.com/bcgov/aries-cloudagent-container](https://github.com/bcgov/aries-cloudagent-container). Appropriate permissions are required to publish the image.
[publish.yml]: https://github.com/hyperledger/aries-cloudagent-python/blob/main/.github/workflows/publish.yml
[publish-indy.yml]: https://github.com/hyperledger/aries-cloudagent-python/blob/main/.github/workflows/publish-indy.yml
[Container Images and Github Actions]: https://github.com/hyperledger/aries-cloudagent-python/blob/main/ContainerImagesAndGithubActions.md

10. Update the ACA-Py Read The Docs site by building the new "latest" (main branch) and activating and building the new release. Appropriate permissions are required to publish the new documentation version.
10. Update the ACA-Py Read The Docs site by building the new "latest" (main
branch) and activating and building the new release. Appropriate permissions
are required to publish the new documentation version.
8 changes: 8 additions & 0 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ def add_arguments(self, parser: ArgumentParser):
"credential offers"
),
)
parser.add_argument(
"--disable-multiple-credential-flow",
action="store_true",
env_var="ACAPY_DISABLE_MULTIPLE_CREDENTIAL_FLOW",
help=("Disable multiple credential flow"),
)
parser.add_argument(
"--auto-respond-credential-offer",
action="store_true",
Expand Down Expand Up @@ -461,6 +467,8 @@ def get_settings(self, args: Namespace) -> dict:
settings["debug.auto_accept_requests"] = True
if args.auto_respond_messages:
settings["debug.auto_respond_messages"] = True
if args.disable_multiple_credential_flow:
settings["debug.disable_multiple_credential_flow"] = True
return settings


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def get_format_identifier(self, message_type: str) -> str:
"""

@abstractmethod
def get_format_data(self, message_type: str, data: dict) -> CredFormatAttachment:
def get_format_data(
self, message_type: str, data: dict, attach_id: str = None
) -> CredFormatAttachment:
"""Get credential format and attachment objects for use in cred ex messages."""

@abstractclassmethod
Expand All @@ -81,7 +83,7 @@ async def receive_proposal(

@abstractmethod
async def create_offer(
self, cred_proposal_message: V20CredProposal
self, cred_proposal_message: V20CredProposal, attach_id: str = None
) -> CredFormatAttachment:
"""Create format specific credential offer attachment data."""

Expand All @@ -93,7 +95,11 @@ async def receive_offer(

@abstractmethod
async def create_request(
self, cred_ex_record: V20CredExRecord, request_data: Mapping = None
self,
cred_ex_record: V20CredExRecord,
request_data: Mapping = None,
attach_id: str = None,
init_cred_req_flow: bool = False,
) -> CredFormatAttachment:
"""Create format specific credential request attachment data."""

Expand All @@ -105,18 +111,24 @@ async def receive_request(

@abstractmethod
async def issue_credential(
self, cred_ex_record: V20CredExRecord, retries: int = 5
self, cred_ex_record: V20CredExRecord, retries: int = 5, attach_id: str = None
) -> CredFormatAttachment:
"""Create format specific issue credential attachment data."""

@abstractmethod
async def receive_credential(
self, cred_ex_record: V20CredExRecord, cred_issue_message: V20CredIssue
self,
cred_ex_record: V20CredExRecord,
cred_issue_message: V20CredIssue,
attach_id: str = None,
) -> None:
"""Create format specific issue credential message."""

@abstractmethod
async def store_credential(
self, cred_ex_record: V20CredExRecord, cred_id: str = None
self,
cred_ex_record: V20CredExRecord,
cred_id: str = None,
attach_id: str = None,
) -> None:
"""Store format specific credential from issue credential message."""
Loading

0 comments on commit 725faf7

Please sign in to comment.