name: release # Pushing v1.2.3 creates the release and attaches the source archive. There is # no binary: whoson only builds on z/OS, # which no hosted runner provides. on: push: tags: ['v[0-9]*'] permissions: contents: write jobs: release: runs-on: ubuntu-latest steps: # v7.0.1, pinned to a commit: a tag can be repointed at other code. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: persist-credentials: false fetch-depth: 0 - name: tag matches VERSION run: | version=$(sed -n 's/^VERSION[[:space:]]*=[[:space:]]*//p' Makefile) if [ "v$version" != "$GITHUB_REF_NAME" ]; then echo "tag $GITHUB_REF_NAME does not match VERSION=$version" >&2 exit 1 fi echo "VERSION=$version" >> "$GITHUB_ENV" - name: source archive run: | git archive --format=tar.gz --prefix="whoson-$VERSION/" \ -o "whoson-$VERSION.tar.gz" "$GITHUB_SHA" sha256sum "whoson-$VERSION.tar.gz" > "whoson-$VERSION.tar.gz.sha256" - name: notes from the changelog run: | awk -v v="$VERSION" \ 'BEGIN { p = 0 } $0 ~ "^## " v "$" { p = 1; next } p && /^## / { exit } p' CHANGELOG.md > notes.md if [ ! -s notes.md ]; then echo "CHANGELOG.md has no '## $VERSION' section" >&2 exit 1 fi - name: release env: GH_TOKEN: ${{ github.token }} run: | gh release create "$GITHUB_REF_NAME" \ --title "whoson $VERSION" \ --notes-file notes.md \ "whoson-$VERSION.tar.gz" "whoson-$VERSION.tar.gz.sha256"