Create new Release #7
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
name: Create new Release | |
on: | |
repository_dispatch: | |
types: perform-release | |
workflow_dispatch: | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Prepare Release | |
run: | | |
CURRENT_VERSION_LONG=$(curl --silent "https://api.github.com/repos/SAP/devops-docker-neo-cli/releases" | jq -r '.[].tag_name' | head -n1) | |
echo Current version: $CURRENT_VERSION_LONG | |
CURRENT_VERSION=`echo $CURRENT_VERSION_LONG | cut -c 2- | cut -d. -f1` | |
NEXT_VERSION=v$(expr $CURRENT_VERSION + 1) | |
echo Next version: $NEXT_VERSION | |
STATUS_CODE_FOR_NEXT_RELEASE=$(curl -s -o /dev/null -w "%{http_code}" "https://api.github.com/repos/SAP/devops-docker-neo-cli/releases/tags/$NEXT_VERSION") | |
if [ "$STATUS_CODE_FOR_NEXT_RELEASE" != "404" ]; then | |
echo "Planned next release version ($NEXT_VERSION) already exists, aborting process" | |
exit 1 | |
fi | |
echo "PIPER_version=$NEXT_VERSION" >> $GITHUB_ENV | |
- name: Build and push | |
run: | | |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USER }} --password-stdin | |
echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin | |
docker build -t ppiper/neo-cli:${{ env.PIPER_version }} . | |
docker tag ppiper/neo-cli:${{ env.PIPER_version }} ghcr.io/sap/ppiper-neo-cli:${{ env.PIPER_version }} | |
docker push ppiper/neo-cli:${{ env.PIPER_version }} | |
docker push ghcr.io/sap/ppiper-neo-cli:${{ env.PIPER_version }} | |
- uses: SAP/project-piper-action@master | |
with: | |
piper-version: latest | |
command: githubPublishRelease | |
flags: --token ${{ secrets.GITHUB_TOKEN }} |