pulumi/.github/workflows/ci-info.yml

105 lines
3.2 KiB
YAML

name: Info
on:
workflow_call:
inputs:
ref:
required: true
description: "GitHub ref to use"
type: string
is-snapshot:
required: false
default: true
description: "Is this a snapshot release?"
type: boolean
outputs:
version:
description: "Version to produce"
value: ${{ jobs.info.outputs.version }}
release-notes:
description: "Release notes for CHANGELOG"
value: ${{ jobs.info.outputs.release-notes }}
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
info:
name: gather
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: "${{ fromJSON(steps.version.outputs.version) }}"
release-notes: "${{ fromJSON(steps.notes.outputs.release-notes) }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
- name: Print rate limits
continue-on-error: true
run: gh api -i repos/${{ github.repository }}/releases/latest
- name: Compute version
id: version
env:
IS_SNAPSHOT: ${{ inputs.is-snapshot }}
run: |
PLAIN_VERSION="$(./.github/scripts/get-version)"
PULUMI_VERSION="${PLAIN_VERSION}"
if [ "$IS_SNAPSHOT" = "true" ]; then
TIMESTAMP=$(date +%s)
PULUMI_VERSION="${PULUMI_VERSION%-*}-alpha.$TIMESTAMP"
fi
./.github/scripts/set-output version "${PULUMI_VERSION}"
- uses: actions/setup-go@v5
with:
go-version: '>=1.19.0' # decoupled from version sets, used by changelog tool
cache: true
cache-dependency-path: '.github/scripts/get-changelog'
- name: Extract release notes
id: notes
run: |
PREVIOUS_VERSION="$(./.github/scripts/get-previous-version)"
CHANGELOG="$(./.github/scripts/get-changelog "${PREVIOUS_VERSION}" --version "${{ fromJSON(steps.version.outputs.version) }}")"
./.github/scripts/set-output release-notes "${CHANGELOG}"
- name: Check version
if: ${{ !inputs.is-snapshot }}
run: |
PULUMI_VERSION="${{ fromJSON(steps.version.outputs.version) }}"
./.github/scripts/update-versions "${PULUMI_VERSION}"
ERROR=false
if [ -n "$(git status --porcelain)" ]; then
ERROR=true
echo "::error::Versions in files do not match expected version ${PULUMI_VERSION}."
echo "::group::git diff"
git diff
echo "::endgroup::"
fi
if EXISTING_RELEASE_DRAFT="$(gh release view "v${PULUMI_VERSION}" --json isDraft --jq '.isDraft')"; then
if [ "$EXISTING_RELEASE_DRAFT" != "true" ]; then
echo "::error::This version has already been released!"
echo "::group::Release ${PULUMI_VERSION}"
echo "$EXISTING_RELEASE"
echo "::endgroup::"
else
echo "::info Preparing to update draft release ${PULUMI_VERSION}"
fi
fi
if $ERROR; then
exit 1;
fi