-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PR] #15 from Aleksanaa: Add release workflow
- Loading branch information
Showing
1 changed file
with
115 additions
and
0 deletions.
There are no files selected for viewing
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
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 github-actions@github.com | ||
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 github-actions@github.com | ||
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 }} |