Release workflow #2
Workflow file for this run
This file contains hidden or 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: release | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| jobs: | |
| collect-modules: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| modules: ${{ steps.collect-modules.outputs.modules }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: collect modules | |
| id: collect-modules | |
| run: | | |
| modules=$(find . -name .releaserc.yaml | \ | |
| xargs -I {} dirname {} | \ | |
| jq -R '[.]' | jq -s -c 'add') | |
| echo "modules=$modules" >> $GITHUB_OUTPUT | |
| release-modules: | |
| needs: [ "collect-modules" ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| module: ${{fromJson(needs.collect-modules.outputs.modules)}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Fetch tags | |
| run: git fetch --prune --tags | |
| - name: collect module info | |
| id: module-info | |
| run: | | |
| module_path="${{ matrix.module }}" | |
| module_name=$(yq .module.name $module_path/.releaserc.yaml) | |
| module_version=$(yq .module.version $module_path/.releaserc.yaml) | |
| tag_exists=$(git tag -l | grep -q $module_name-$module_version && echo true || echo false) | |
| echo "module_name=$module_name" >> $GITHUB_OUTPUT | |
| echo "module_version=$module_version" >> $GITHUB_OUTPUT | |
| echo "tag_exists=$tag_exists" >> $GITHUB_OUTPUT | |
| - name: publish module | |
| if: steps.module-info.outputs.tag_exists == 'false' | |
| run: | | |
| module_path="${{ matrix.module }}" | |
| module_name=$(yq .module.name $module_path/.releaserc.yaml) | |
| module_version=$(yq .module.version $module_path/.releaserc.yaml) | |
| tar \ | |
| --exclude='.terraform' \ | |
| --exclude='*.tfstate*' \ | |
| --exclude='*_override.tf*' \ | |
| -C $module_path \ | |
| -czvf terraform-${module_name}-${module_version}.tar.gz . | |
| - name: release module | |
| if: steps.module-info.outputs.tag_exists == 'false' | |
| run: | | |
| module_name=${{ steps.module-info.outputs.module_name }} | |
| module_version=${{ steps.module-info.outputs.module_version }} | |
| # git tag $module_name-$module_version | |
| # git push origin $module_name-$module_version |