|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + version: |
| 6 | + description: The release version to create (e.g. 1.2.3). |
| 7 | + required: true |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: bash |
| 12 | + |
| 13 | +jobs: |
| 14 | + |
| 15 | + determine-version: |
| 16 | + name: Validate sanity check the requested version |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + release-version: ${{ steps.determine-version.outputs.release-version }} |
| 20 | + steps: |
| 21 | + - name: Determine release version |
| 22 | + id: determine-version |
| 23 | + run: | |
| 24 | + version="${{ inputs.version }}" |
| 25 | +
|
| 26 | + if [[ -z "$version" ]]; then |
| 27 | + echo "::error::An input 'version' must be specified" |
| 28 | + exit 1 |
| 29 | +
|
| 30 | + elif (( ${#version} > 7 )); then |
| 31 | + echo "::error::The input 'version' must be smaller than 8 characters (i.e. allows '2.99.99')" |
| 32 | + exit 1 |
| 33 | +
|
| 34 | + elif [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 35 | + echo "::error::The input version '${version}' must be of the form MAJOR.MINOR.PATCH (8.9.10)" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | +
|
| 39 | + echo "::notice::Release version is: ${version}" |
| 40 | + echo "release-version=${version}" >> $GITHUB_OUTPUT |
| 41 | +
|
| 42 | + run-ci: |
| 43 | + needs: determine-version |
| 44 | + uses: ./.github/workflows/ci.yml |
| 45 | + |
| 46 | + github-release: |
| 47 | + name: Create a Github Release with build provenance attestations |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: |
| 50 | + - determine-version |
| 51 | + - run-ci |
| 52 | + permissions: |
| 53 | + attestations: write |
| 54 | + contents: write |
| 55 | + id-token: write |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Download artifacts |
| 59 | + uses: actions/download-artifact@v8 |
| 60 | + with: |
| 61 | + name: ${{ needs.run-ci.outputs.artifact-name }} |
| 62 | + |
| 63 | + - name: Generate |
| 64 | + env: |
| 65 | + GH_TOKEN: ${{ github.token }} |
| 66 | + RELEASE_VERSION: ${{ steps.determine-version.outputs.release-version }} |
| 67 | + ARTIFACT_PATH: ${{ needs.run-ci.outputs.artifact-path }} |
| 68 | + run: | |
| 69 | + gh release create \ |
| 70 | + "${RELEASE_VERSION}" \ |
| 71 | + "${ARTIFACT_PATH}" \ |
| 72 | + --fail-on-no-commits \ |
| 73 | + --generate-notes \ |
| 74 | + --repo sureshjoshi/pantsible |
| 75 | + |
| 76 | + - name: Generate ${{ needs.determine-version.outputs.release-version }} build provenance attestations |
| 77 | + uses: actions/attest@v4 |
| 78 | + with: |
| 79 | + subject-path: ${{ needs.run-ci.outputs.artifact-path }} |
| 80 | + |
0 commit comments