Skip to content

Update pulp binding if new release #660

Update pulp binding if new release

Update pulp binding if new release #660

Workflow file for this run

name: Update pulp binding if new release
on:
push:
schedule:
- cron: "0 7 * * *"
jobs:
CheckLatestVersionAndRun:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
with:
fetch-depth: 0 # Needed for github-action-get-previous-tag
uses: actions/checkout@v3
- name: Get current build version
id: repoRelease
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
prefix: release/
fallback: 1.0.0 # Optional fallback tag to use when no tag can be found
- name: Get current pulp version
id: pulpRelease
run: |
latestImage="`curl https://quay.io/v1/repositories/redhat-services-prod/pulp-services-tenant/pulp/tags/latest | jq -r`"
date="`curl https://quay.io/v2/redhat-services-prod/pulp-services-tenant/pulp/manifests/latest | jq -r '.history[].v1Compatibility' | jq -r '.created' | head -n 1`"
year=`date -d "$date" +%Y`
month=`date -d "$date" +%-m`
epoch=`date -d "$date" +"%s"`
pulpTag="$year.$month.$epoch"
echo "GIT_TAG=release/v$pulpTag" >> $GITHUB_OUTPUT
echo "PULP_TAG=$latestImage" >> $GITHUB_OUTPUT
echo "MAJOR_VERSION=v$year" >> $GITHUB_OUTPUT
echo "PULP_MAJOR=v3" >> $GITHUB_OUTPUT
# If check passes, latest build is up to date and the action stops
- name: Update version
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
run: |
echo "New pulp version available >> ${{ steps.pulpRelease.outputs.PULP_TAG }}! (Current build version ${{ steps.repoRelease.outputs.tag }})"
- name: Setup docker compose
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
uses: isbang/[email protected]
with:
compose-file: docker-compose.yml
cwd: ./docker/
down-flags: --volumes
- name: Remove old files
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
run: |
rm -rf release/
- name: Wait for pulp
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
run: |
docker run --network=host --rm -v ${PWD}:/local curlimages/curl \
curl --retry-all-errors --fail --retry-delay 10 --retry 32 --retry-max-time 240 http://localhost:8080/api/pulp/api/${{ steps.pulpRelease.outputs.PULP_MAJOR }}/docs/api.json
- name: Build binding
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
run: |
curl http://localhost:8080/api/pulp/api/${{ steps.pulpRelease.outputs.PULP_MAJOR }}/docs/api.json > pulp_api.json
echo "$( jq '.components.schemas.TaskResponse.properties.error.additionalProperties.type = "string"' ./pulp_api.json )" > ./pulp_api.json
cat pulp_api.json | sed 's/\\n//g' > pulp_api_new.json #remove \n characters that break generation
mv pulp_api_new.json pulp_api.json
docker run --network=host --rm -v ${PWD}:/local openapitools/openapi-generator-cli:latest-release generate \
-i /local/pulp_api.json \
-t /local/templates/ \
-g go \
-o /local/release --minimal-update --skip-validate-spec \
--git-user-id=content-services --git-repo-id=zest/release/${{ steps.pulpRelease.outputs.MAJOR_VERSION }} \
--package-name=zest -p enumClassPrefix=true -p structPrefix=true \
-p disallowAdditionalPropertiesIfNotPresent=false \
-p packageVersion=${{ steps.pulpRelease.outputs.PULP_TAG }} \
--global-property skipFormModel=false #for ansible plugin
- name: Archive api json
uses: actions/upload-artifact@v3
with:
name: pulp_api.json
path: pulp_api.json
- uses: actions/setup-go@v2
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
with:
go-version: "1.22"
- name: Run Go Tests
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
run: |
cd release
sudo chmod 777 go.mod go.sum
go get github.com/stretchr/testify/assert
go test ./...
- name: Commit new client
id: commit
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
run: |
git config --global user.name ${{secrets.GIT_USER_NAME}}
git config --global user.email ${{secrets.GIT_USER_EMAIL}}
git add release/
git commit -am "Update pulp bindings to ${{ steps.pulpRelease.outputs.PULP_TAG }}"
git push
echo "NEW_SHA=`git rev-parse HEAD`" >> $GITHUB_OUTPUT
# This pushes an update and release after build <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- name: Tag and Release version
if: steps.pulpRelease.outputs.GIT_TAG != steps.repoRelease.outputs.tag
uses: avakar/tag-and-release@v1
with:
commit: ${{steps.commit.outputs.NEW_SHA}}
tag_name: ${{ steps.pulpRelease.outputs.GIT_TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}