Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow #15

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: release
on:
push:
branches:
- "release/*"

jobs:
testing:
name: testing release
runs-on: ubuntu-latest
if: ${{ !startsWith(github.event.head_commit.message,'release') }}

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Get tags
run: git fetch --all --tags

- name: Get version
run: |
BRANCH=$(git symbolic-ref --short HEAD)
VER=${BRANCH#*release/}
if [[ $(git tag | grep ${VER}rc) ]];then
TAGS=$(git tag | grep ${VER}rc | awk 'END {print}')
REL=${TAGS##*rc}
let REL++
else
REL=1
fi
echo "BUILDVER=${VER}rc${REL}" >> $GITHUB_ENV

- name: Update versions
run: |
sed -i "/^ *VERSION = /cVERSION = '${{ env.BUILDVER }}'" hyfetch/constants.py

- name: Making tags
run: |
git config user.name github-actions
git config user.email [email protected]
git stage .
git commit -m "tagged unstable ${{ env.BUILDVER }}"
git tag --force ${{ env.BUILDVER }}

- name: Upload changes
run: |
git pull && git push && git push --tags

- name: Deploy to PYPI
uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
pip: wheel -w dist/ --no-deps .

release:
name: formal release
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message,'release') }}

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get version
run: |
BRANCH=$(git symbolic-ref --short HEAD)
echo "BUILDVER=${BRANCH#*release/}" >> $GITHUB_ENV

- name: Update package.json
uses: jossef/action-set-json-field@v2
with:
file: package.json
field: version
value: ${{ env.BUILDVER }}

- name: Update neofetch version
run: |
REVISION=$(expr $(git rev-list --count HEAD neofetch) - 2902)
sed -i "/^ *version=/cversion=7.4.0r${REVISION}" neofetch

- name: Update other versions
run: |
sed -i "/^ *VERSION = /cVERSION = '${{ env.BUILDVER }}'" hyfetch/constants.py
sed -i "/^ *### Unpublished/c### ${{ env.BUILDVER }}" README.md

- name: Make final tags
run: |
git config user.name github-actions
git config user.email [email protected]
git stage . && git commit -m "tagged stable ${{ env.BUILDVER }}"
git tag --force ${{ env.BUILDVER }}

- name: Merge branch and push
run: |
parent=$(git show-branch \
| grep -F '*' \
| grep -v "$(git rev-parse --abbrev-ref HEAD)" \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//')
git checkout ${parent}
git merge release/${{ env.BUILDVER }} --allow-unrelated-histories
git pull --all && git push --all && git push --tags

- name: Generate changelog from README
run: (sed '0,/^ *### ${{ env.BUILDVER }}/d;/^ *#/,$d' <README.md)>temp_CHANGELOG.md

- name: Publish release
uses: ncipollo/release-action@v1
with:
bodyFile: "temp_CHANGELOG.md"
tag: ${{ env.BUILDVER }}
token: ${{ secrets.GITHUB_API_TOKEN }}