Skip to content

Commit 9bcd4e4

Browse files
initial commit
0 parents  commit 9bcd4e4

File tree

8 files changed

+168
-0
lines changed

8 files changed

+168
-0
lines changed

AUTHORS.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Contributors
2+
------------
3+
4+
|contributors|
5+
6+
.. |contributors| image:: https://contributors-img.web.app/image?repo=python-semantic-release/upload-to-gh-release
7+
:target: https://github.com/python-semantic-release/upload-to-gh-release/graphs/contributors

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CHANGELOG
2+
3+
## Initial version
4+
5+
Initial Action version

CONTRIBUTING.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Contributing
2+
------------
3+
4+
If you want to contribute that is awesome. Remember to be nice to others in issues and reviews.
5+
6+
Please remember to write tests for the cool things you create or fix.
7+
8+
Unsure about something? No worries, `open an issue`_.
9+
10+
.. _open an issue: https://github.com/python-semantic-release/upload-to-gh-release/issues/new

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG PYTHON_VERSION=3.10
2+
3+
FROM python:${PYTHON_VERSION}
4+
5+
RUN set -ex; \
6+
apt-get update; \
7+
apt-get install -y --no-install-recommends \
8+
git-lfs
9+
10+
#install backported stable vesion of git, which supports ssh signing
11+
RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list; \
12+
apt-get update;\
13+
apt-get install -y git/bullseye-backports \
14+
&& apt-get clean \
15+
&& rm -rf /var/lib/apt/lists/*; \
16+
mkdir /semantic-release
17+
18+
WORKDIR /semantic-release
19+
20+
COPY action.sh /semantic-release/action.sh
21+
22+
RUN pip install --pre --no-cache-dir "python-semantic-release<9"; \
23+
semantic-release --help
24+
25+
ENTRYPOINT ["/semantic-release/action.sh"]

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023-present Bernard Cooke
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Python Semantic Release - Upload to GitHub Release Action
2+
3+
This GitHub Action runs `semantic-release publish` using
4+
[`python-semantic-release`](https://github.com/python-semantic-release/python-semantic-release).
5+
Full documentation is available in the [documentation](https://python-semantic-release.readthedocs.io/en/latest/)
6+
for Python Semantic Release.
7+
8+
**NOTE**: This Action is compatible only with Python Semantic Release v8 or higher.
9+
10+
## Example usage
11+
12+
```yaml
13+
---
14+
name: CI
15+
16+
on:
17+
push:
18+
branches:
19+
- main
20+
21+
jobs:
22+
release:
23+
runs-on: ubuntu-latest
24+
concurrency: release
25+
26+
# NOTE: this enables trusted publishing.
27+
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1#trusted-publishing
28+
# and https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/
29+
permissions:
30+
id-token: write
31+
32+
steps:
33+
- uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Python Semantic Release
38+
uses: python-semantic-release/[email protected]
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
# <other options here>
42+
43+
- name: Publish package to PyPI
44+
uses: pypa/gh-action-pypi-publish@release/v1
45+
46+
- name: Publish package to GitHub Release
47+
uses: python-semantic-release/upload-to-gh-release@main
48+
with:
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
```
51+
52+
## Options
53+
54+
See [action.yml](./action.yml) for a description of the available options.

action.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Copy inputs into correctly-named environment variables
6+
export GH_TOKEN="${INPUT_GITHUB_TOKEN}"
7+
export ROOT_OPTIONS="${INPUT_ROOT_OPTIONS:="-v"}"
8+
9+
# Change to configured directory
10+
cd "${INPUT_DIRECTORY}"
11+
12+
# See https://github.com/actions/runner-images/issues/6775#issuecomment-1409268124
13+
# and https://github.com/actions/runner-images/issues/6775#issuecomment-1410270956
14+
git config --system --add safe.directory "*"
15+
16+
# Run Semantic Release
17+
semantic-release ${ROOT_OPTIONS} publish --upload-to-vcs-release

action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: "Python Semantic Release - Publish"
3+
4+
description: "Publish Python Wheels and other Artefacts to GitHub Releases"
5+
6+
inputs:
7+
root_options:
8+
description: |
9+
Additional options for the root `semantic-release` command.
10+
Example: -vv --noop
11+
required: false
12+
default: "-v"
13+
14+
directory:
15+
description: |
16+
Sub-directory to cd into before running semantic-release publish
17+
default: "."
18+
required: false
19+
20+
github_token:
21+
description: |
22+
GitHub token used to upload artefacts. Requires permission to create and
23+
edit releases.
24+
required: true
25+
26+
runs:
27+
using: "docker"
28+
image: "Dockerfile"

0 commit comments

Comments
 (0)