Skip to content

Push to PyPI

Push to PyPI #3

Workflow file for this run

name: Push to PyPI
on:
release:
types: [released]
jobs:
release-obs:
name: Release on OBS
runs-on: ubuntu-latest
env:
OBS_API: https://api.opensuse.org/
PROJECT: home:ChHuang
PACKAGE: python-osc-tiny
steps:
- uses: actions/checkout@master
- name: Get latest release tag
id: get_latest_release
run: echo "LATEST_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Install osc
run: |
sudo apt-get update -y
sudo apt-get install -y osc
- name: Config osc
run: |
cat <<EOF > $HOME/.oscrc
[general]
apiurl=$OBS_API
[$OBS_API]
user = ${{ secrets.OSC_USER }}
pass = ${{ secrets.OSC_PASS }}
EOF
- name: checkout package
run: |
osc branchco $PROJECT $PACKAGE
cd $PROJECT:branches:$PROJECT/$PACKAGE
rm *.tar.gz
- name: Fetch tarball from PyPI
id: fetch-tarball
run: |
FILE_NAME=osc-tiny-$LATEST_TAG.tar.gz
FILE_URL="https://files.pythonhosted.org/packages/source/o/osc-tiny/osc_tiny-$LATEST_TAG.tar.gz -O $FILE_NAME"
while [ ! -f "$FILE_NAME" ]; do
echo "File not found. Downloading..."
curl -O $FILE_URL
if [ ! -f "$FILE_NAME" ]; then
echo "Download failed. Waiting for 2 seconds before retrying..."
sleep 2
fi
done
echo "File downloaded successfully!"
- name: Update version in spec file
run: |
sed -i "s/^Version:.*/Version: $LATEST_TAG/" *.spec
- name: Commit and push changes
run: |
osc vc -m 'Update to version $LATEST_TAG'
osc commit -m "Update to version $LATEST_TAG"
- name: Submit changes to OBS
run: |
osc submitrequest -m "Update package to version $LATEST_TAG"