Skip to content

Commit

Permalink
feat: add --version flag for external debugging
Browse files Browse the repository at this point in the history
This contribution is part of the [FC-0012 project](https://openedx.atlassian.net/l/cp/XGS0iCcQ) which is sparked by the [Translation Infrastructure update OEP-58](https://open-edx-proposals.readthedocs.io/en/latest/architectural-decisions/oep-0058-arch-translations-management.html#specification).
  • Loading branch information
OmarIthawi committed Aug 1, 2023
1 parent 3518475 commit 0bc1f23
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Releases

on:
on:
push:
tags:
- '*'
Expand All @@ -12,6 +12,12 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v3
- name: set tag variable in atlas
run: |
# Sets _ATLAS_VERSION to the latest tag
CURRENT_TAG=$(git describe --exact-match --tags)
sed -i -e "s/_ATLAS_VERSION=.*/_ATLAS_VERSION=\"${CURRENT_TAG}\" # Tagged by release.yml/" atlas
- uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
artifacts: "atlas"
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ Releasing a New Version
-----------------------
This repository uses `semantic versioning <https://semver.org/>`_. To release a new version:

* Cut a git tag with the new version number either via command-line e.g. ``git tag v1.0.0`` or the GitHub UI.
* Wait for the ``release.yml`` GitHub Action to complete successfully, which uploads the latest ``atlas`` file to the release.
* Edit the new release on GitHub to add release notes.
* Cut a git tag with the new version number either via the GitHub UI or command-line e.g. ``git tag v1.0.0``.
* The ``release.yml`` GitHub Action sets the version number for ``atlas --version`` and creates a new release with ``atlas``.

License
-------
Expand Down
9 changes: 9 additions & 0 deletions atlas
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# getoptions generates code that fails this check, so we need to disable it
# shellcheck disable=SC2004

# Atlas uses semantic versioning (https://semver.org/). To cut a new release, checkout the README:
# - https://github.com/openedx/openedx-atlas#releasing-a-new-version
_ATLAS_VERSION="unreleased" # release.yml GitHub Action will fill in the tag version

# @getoptions
parser_definition() {
_ATLAS_USAGE_HELP="Atlas is a CLI tool that has essentially one command: \`atlas pull\`
Expand Down Expand Up @@ -78,6 +82,7 @@ More examples are available in the repository docs: https://github.com/openedx/o
msg -- '' 'Commands:'
cmd pull -- "pull"
disp :usage -h --help
disp _ATLAS_VERSION --version
}

parser_definition_pull() {
Expand Down Expand Up @@ -114,6 +119,9 @@ parse() {
'-h'|'--help')
usage
exit 0 ;;
'--version')
echo "${_ATLAS_VERSION}"
exit 0 ;;
--)
while [ $# -gt 0 ]; do
REST="${REST} \"\${$(($OPTIND-$#))}\""
Expand Down Expand Up @@ -221,6 +229,7 @@ More examples are available in the repository docs: https://github.com/openedx/o
Commands:
pull pull
-h, --help
--version
GETOPTIONSHERE
}
# Generated by getoptions (END)
Expand Down
6 changes: 6 additions & 0 deletions spec/version_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Describe 'Test the --version flag'
It 'Prints the version'
When run source ./atlas --version
The output should equal 'unreleased'
End
End

0 comments on commit 0bc1f23

Please sign in to comment.