Skip to content

.github/workflows/release.yml #37

.github/workflows/release.yml

.github/workflows/release.yml #37

Workflow file for this run

---
on:
push:
# ref: https://help.github.com/en/actions/reference/events-that-trigger-workflows#example-using-multiple-events-with-activity-types-or-configuration
tags:
- 'v*'
env:
# Authoritative Cirrus-CI task to monitor for completion info of all other cirrus-ci tasks.
MONITOR_TASK: 'MONITOR/TEST/VALUE'
# Authoritative Github Action task (in cirrus-ci) to trigger / check for completion of _this_ workflow
ACTION_TASK: 'ACTION/TEST/VALUE'
HELPER_LIB_TEST: 'github/test/run_action_tests.sh'
jobs:
smoke:
runs-on: ubuntu-latest
steps:
- name: Confirm privileged registry access
env:
DOCKER_CONFIG_JSON: ${{secrets.DOCKER_CONFIG_JSON}}
run: |
set +x
trap "history -c" EXIT
if [[ -z "$DOCKER_CONFIG_JSON" ]]; then
echo "::error::Empty/unset \$DOCKER_CONFIG_JSON for quay.io/libpod write access"
exit 1
fi
unit-tests: # N/B: Duplicates `ubuntu_unit_tests.yml` - templating not supported
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# Testing installer requires a full repo. history
fetch-depth: 0
persist-credentials: false
path: ./
- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq -y install libtest-differences-perl libyaml-libyaml-perl
- name: Execute helper library unit-tests using code from PR
run: |
$GITHUB_WORKSPACE/$HELPER_LIB_TEST
- name: Fetch all repository tags
run: git fetch --tags --force
- name: Execute all unit-tests
run: $GITHUB_WORKSPACE/bin/run_all_tests.sh
release:
needs:
- unit-tests
- smoke
# Don't blindly trust the 'v*' push event filter.
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
runs-on: ubuntu-latest
steps:
# At the time of this comment, there is NO other source or method for
# obtaining the pushed tag from any function, env. var., event JSON, or
# context data.
- id: get_tag
name: Retrieve the tag name
run: printf "TAG_NAME=%s\n" $(basename "$GITHUB_REF") >> $GITHUB_OUTPUT
- id: create_release # Pre-req for upload-release-asset below
name: Create a new Github Release item for tag
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_tag.outputs.TAG_NAME }}
release_name: ${{ steps.get_tag.outputs.TAG_NAME }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: ./
- uses: actions/upload-release-asset@v1.0.2
name: Upload the install script as the release artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/install_automation.sh
asset_name: install_automation.sh
asset_content_type: application/octet-stream
container_image:
needs:
- unit-tests
- smoke
runs-on: ubuntu-latest
env:
REGISTRY: quay.io
REPO_USER: libpod
REPO_NAME: cirrus-ci_retrospective
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: ./
- name: Build the cirrus-ci_retrospective container image
run: >-
docker build -t $REGISTRY/$REPO_USER/$REPO_NAME:latest \
-f cirrus-ci_retrospective/Dockerfile \
--build-arg INSTALL_AUTOMATION_VERSION=0.0.0 \
./
- name: Configure registry credentials
env:
DOCKER_CONFIG_JSON: ${{secrets.DOCKER_CONFIG_JSON}}
run: |
if [[ -z "$DOCKER_CONFIG_JSON" ]]; then
echo "::error::Empty/unset \$DOCKER_CONFIG_JSON"
exit 1
fi
trap "history -c" EXIT
mkdir -p $HOME/.docker
echo "$DOCKER_CONFIG_JSON" > $HOME/.docker/config.json
- name: Retrieve the tag name
id: get_tag
run: printf "TAG_NAME=%s\n" $(basename "$GITHUB_REF" | tee /dev/stderr) >> $GITHUB_OUTPUT
- name: Tag and push cirrus-ci_retrospective container image to registry
run: |
docker tag $REGISTRY/$REPO_USER/$REPO_NAME:latest \
$REGISTRY/$REPO_USER/$REPO_NAME:${{ steps.get_tag.outputs.TAG_NAME }}
docker push $REGISTRY/$REPO_USER/$REPO_NAME:${{ steps.get_tag.outputs.TAG_NAME }} && \
docker push $REGISTRY/$REPO_USER/$REPO_NAME:latest
debug:
runs-on: ubuntu-latest
steps:
- if: always()
name: Log colorized and formatted event JSON
run: jq --indent 4 --color-output . ${{ github.event_path }}
- if: always()
uses: actions/upload-artifact@v4.3.2
name: Archive triggering event JSON
with:
name: event.json.zip
path: ${{ github.event_path }}