Skip to content

WIP

WIP #358

Workflow file for this run

---
name: Release
on:
push:
tags:
- "**"
permissions:
contents: write
jobs:
preflight:
runs-on: ubuntu-latest
outputs:
is_pre_release: ${{ steps.get_version_info.outputs.is_pre_release }}
module_name: ${{ steps.get_version_info.outputs.module_name }}
tag: ${{ steps.get_version_info.outputs.tag }}
version: ${{ steps.get_version_info.outputs.version }}
steps:
- id: get_version_info
name: Get version info
run: |
TAG="${GITHUB_REF#refs/*/}"
if [[ "$TAG" =~ ^[a-zA-Z0-9-]+\/[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9-]+)?$ ]]; then
MODULE_NAME=$(echo "$TAG" |cut -d/ -f 1)
VERSION=$(echo "$TAG" |cut -d/ -f 2)
else
echo "Invalid tag format: $TAG"
exit 1
fi
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
IS_PRE_RELEASE="false"
else
IS_PRE_RELEASE="true"
fi
echo "is_pre_release=${IS_PRE_RELEASE}"
echo "is_pre_release=${IS_PRE_RELEASE}" >> "$GITHUB_OUTPUT"
echo "module_name=${MODULE_NAME}"
echo "module_name=${MODULE_NAME}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
build:
uses: ./.github/workflows/build.yml
needs: preflight
release:
runs-on: ubuntu-latest
needs:
- preflight
- build
steps:
- uses: actions/checkout@v4
- name: Update version in module README
run: |
sed -i "s/\[VERSION\]/${{ needs.preflight.outputs.version }}/g" "modules/${{ needs.preflight.outputs.module_name }}/README.md"
- id: create_release_assets
name: Create release assets
run: |
ASSET_PATH="${{ runner.temp }}"
rm -rf "${ASSET_PATH}/module.tar.gz"
pushd "modules/${{ needs.preflight.outputs.module_name }}"
tar -czvf "${ASSET_PATH}/module.tar.gz" --exclude="./test" ./
cp "README.md" "${ASSET_PATH}/README.md"
popd
echo "asset_path=$ASSET_PATH" >> "$GITHUB_OUTPUT"
working-directory: ${{ github.workspace }}
- id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: "${{ steps.create_release_assets.outputs.asset_path }}/README.md"
prerelease: ${{ needs.preflight.outputs.is_pre_release }}
release_name: ${{ needs.preflight.outputs.tag }}
tag_name: ${{ github.ref }}
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "${{ steps.create_release_assets.outputs.asset_path }}/module.tar.gz"
asset_name: module.tar.gz
asset_content_type: application/gzip