Add support to build release containers #65
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: pre-release | |
| on: | |
| push: | |
| tags: [ "[0-9]+.[0-9]+.[0-9]+*" ] | |
| env: | |
| GIT_CLIFF_VERSION: 2.12.0 | |
| GL_VERSION: 2150.1.0 | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main | |
| - run: make docs | |
| - if: ${{ github.ref_name != 'main' }} | |
| name: Upload as artifact | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # pin@v7.0.0 | |
| with: | |
| name: docs | |
| path: _build/ | |
| - if: ${{ github.ref_name == 'main' }} | |
| name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 | |
| with: | |
| publish_branch: gh-pages | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: _build | |
| force_orphan: true | |
| create-pre-release: | |
| if: ${{ github.ref_name == 'main' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout commit | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| cliff.toml | |
| sparse-checkout-cone-mode: false | |
| - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main | |
| - name: Use cargo cache | |
| id: cache-cargo | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo | |
| key: gh-release-${{ runner.os }}-git-cliff-${{ env.GIT_CLIFF_VERSION }}- | |
| restore-keys: gh-release-${{ runner.os }}-git-cliff-${{ env.GIT_CLIFF_VERSION }}-${{ hashFiles('~/.cargo/.crates.toml') }}- | |
| - name: Install git-cliff | |
| if: steps.cache-cargo.outputs.cache-hit != 'true' | |
| run: | | |
| cargo install git-cliff@${GIT_CLIFF_VERSION} | |
| - name: Get the Git tag name | |
| id: get-tag-name | |
| run: echo "tag-name=${GITHUB_REF/refs\/tags\//}" | tee -a "$GITHUB_OUTPUT" | |
| - id: release | |
| name: Create changelog and release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gl-gh-release create \ | |
| --repo "python-gardenlinux-lib" \ | |
| --tag "${{ steps.get-tag-name.outputs.tag-name }}" \ | |
| --commit "${{ github.sha }}" \ | |
| --name 'python-gardenlinux-lib v${{ steps.get-tag-name.outputs.tag-name }}' \ | |
| --latest \ | |
| --body " | |
| $(git-cliff -o - --current) | |
| " | |
| create-oci-release: | |
| if: ${{ github.ref_name == 'main' }} | |
| runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-latest-arm' || 'ubuntu-latest' }} | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| arch: [amd64, arm64] | |
| steps: | |
| - name: Checkout commit | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| src/oci | |
| sparse-checkout-cone-mode: false | |
| - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main | |
| - name: Get the Git tag name | |
| id: get-tag-name | |
| run: echo "tag-name=${GITHUB_REF/refs\/tags\//}" | tee -a "$GITHUB_OUTPUT" | |
| - name: Create OCI container and release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gl-oci build-container \ | |
| --container "ghcr.io/${{ github.repository }}/container" \ | |
| --tag "${{ matrix.arch }}-${{ steps.get-tag-name.outputs.tag-name }}" \ | |
| --oci_archive "container_${{ matrix.arch }}.oci" \ | |
| --platform linux/${{ matrix.arch }} \ | |
| --dir "src/oci" \ | |
| --build_arg GL_VERSION=$GL_VERSION \ | |
| --build_arg PY_GL_VERSION="${{ steps.get-tag-name.outputs.tag-name }}" | |
| gl-oci push-container \ | |
| --container "ghcr.io/${{ github.repository }}/container" \ | |
| --tag "${{ matrix.arch }}-${{ steps.get-tag-name.outputs.tag-name }}" | |
| gl-oci add-container-to-index \ | |
| --index "ghcr.io/${{ github.repository }}/container" \ | |
| --index-tag "${{ steps.get-tag-name.outputs.tag-name }}" \ | |
| --container "ghcr.io/${{ github.repository }}/container" \ | |
| --tag "${{ matrix.arch }}-${{ steps.get-tag-name.outputs.tag-name }}" | |
| - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # pin@v7.0.0 | |
| with: | |
| name: container-${{ matrix.arch }} | |
| path: container_${{ matrix.arch }}.oci | |
| if-no-files-found: error |