-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change versioning The current versioning is considered pre-release. Switching to use a slightly different format to make every release a patch release. The version of the patch release is now the epoch of the latest commit date merged into main Before: 0.2.1-{%Y%m%D%H%M}git{SHA} Now: 0.2.{%s}+{%Y%m%D%H%M}.git{SHA} The + delimits the version from metadata for the release * Build and push manually Due to ansible/galaxy#3287 can't run the GHA ansible/ansible-publish-action without failing, despite the error 500, the collection is published, we are ignoring the 500 until fixed.
- Loading branch information
1 parent
137c9ed
commit 9239258
Showing
2 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,37 @@ jobs: | |
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Add release, date and commit hash to version in galaxy.yml | ||
- name: Add epoch from commit date as patch version and metadata in galaxy.yml | ||
run: > | ||
ts=$(TZ=UTC0 git show ${{ github.sha }} --no-patch --format=%cd --date=format-local:'%Y%m%d%H%M') | ||
z=$(TZ=UTC0 git show ${{ github.sha }} --no-patch --format=%cd --date=format-local:'%s'); | ||
ts=$(TZ=UTC0 git show ${{ github.sha }} --no-patch --format=%cd --date=format-local:'%Y%m%d%H%M'); | ||
sha=$(echo "${{ github.sha }}" | cut -c1-7); | ||
rel=$(grep ^Release ansible-collection-redhatci-ocp.spec | grep -Po '\d+\.'); | ||
sed -i -r "s/^(version: .*)$/&-${rel}${ts}git${sha}/" galaxy.yml; | ||
sed -i -r "s/^(version: .*)\.0$/\1.${z}+${ts}.git${sha}/" galaxy.yml; | ||
grep ^version galaxy.yml | ||
- name: Ansible Publish to Galaxy | ||
uses: ansible/[email protected] | ||
with: | ||
api_key: ${{ secrets.ANSIBLE_GALAXY_TOKEN }} | ||
# Build and publish manually due to https://github.com/ansible/galaxy/issues/3287 | ||
# ansible/ansible-publish-action implements this | ||
# https://github.com/ansible/creator-ee/blob/main/_build/devtools-publish | ||
- name: Ansible Galaxy Collection Publish | ||
run: > | ||
rm -f ./*.tar.gz; | ||
ansible-galaxy collection build -v --force "${SRC_PATH:-.}"; | ||
TARBALL=$(ls -1 ./*.tar.gz); | ||
publish=$(ansible-galaxy collection publish -v \ | ||
--server "${API_SERVER:-https://galaxy.ansible.com/}" \ | ||
--api-key "${{ secrets.ANSIBLE_GALAXY_TOKEN }}" \ | ||
"${TARBALL}" 2>&1 | ||
); | ||
if [[ $? -ne 0 ]]; then | ||
err="Error when publishing collection to cmd_arg .*HTTP Code: 500, Message:"; | ||
err500="Internal Server Error Code: Unknown"; | ||
if grep -qP "${err} ${err500}" <<< "${publish}"; then | ||
echo "Error found https://github.com/ansible/galaxy/issues/3287, Ignoring..."; | ||
echo "${publish}"; | ||
ec=0; | ||
else | ||
echo "${publish}"; | ||
ec=1; | ||
fi; | ||
exit ${ec} | ||
fi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters