Create release #38
Workflow file for this run
This file contains 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: Create release | |
on: | |
push: | |
tags: ['v*'] | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yaml | |
pypi-publish: | |
name: Publish docopt.sh to PyPI | |
needs: [test] | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: .devcontainer/post.sh | |
- name: Set version | |
run: poetry version ${REF/#refs\/tags\/v/} | |
env: | |
REF: ${{ github.ref }} | |
- name: Build | |
run: poetry build | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1.8 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
docopt-lib-release: | |
needs: [test] | |
name: Create docopt-lib.sh GitHub Release | |
runs-on: ubuntu-latest | |
environment: release | |
steps: | |
- name: Determine version | |
id: version | |
run: printf "tag=%s\n" "${REF#refs\/tags\/v}" >> $GITHUB_OUTPUT | |
env: | |
REF: ${{ github.ref }} | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Create release tarball | |
run: | | |
.devcontainer/post.sh | |
poetry version ${{ steps.version.outputs.tag }} | |
poetry install | |
mkdir dist | |
.venv/bin/docopt.sh generate-library >dist/docopt-lib.sh | |
cd dist | |
printf '{ | |
"name": "docopt-lib.sh" | |
"version": "v${{ steps.version.outputs.tag }}" | |
}' | |
tar -czf ../docopt-lib.sh-v${{ steps.version.outputs.tag }}.tar.gz * | |
- name: Get release notes from tag | |
id: tag-message | |
run: | | |
eof="$(openssl rand -hex 8)" | |
msg=$(git tag -l --format='%(contents)' "${REF#refs\/tags\/}") | |
msg=${msg%%'-----BEGIN'*} | |
printf "message<<%s\n%s\n%s\n" "$eof" "$msg" "$eof" >> $GITHUB_OUTPUT | |
env: | |
REF: ${{ github.ref }} | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
name: ${{ steps.version.outputs.tag }} | |
body: ${{ steps.tag-message.outputs.message }} | |
draft: false | |
prerelease: false | |
artifacts: docopt-lib.sh-v${{ steps.version.outputs.tag }}.tar.gz | |
artifactErrorsFailBuild: true | |
artifactContentType: application/gzip |