Skip to content

Publish a release

Publish a release #50

Workflow file for this run

name: Publish a release
on:
workflow_dispatch:
inputs: {}
jobs:
gh_release:
runs-on: ubuntu-latest
outputs:
release_number: ${{ steps.determine_number.outputs.release_number }}
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Jan Buchar"
- name: Determine release number
id: determine_number
run: |
echo release_number=$(( 1 + $(gh release list --json tagName |
jq --raw-output '.[] | .tagName' |
cut -d '-' -f 2 |
sort -n -r |
head -n 1) )) >> "$GITHUB_OUTPUT"
- name: Create branch
run: |
git switch -c ${{ env.PR_BRANCH }}
- name: Update changelog and generate release notes
run: |
git-cliff --tag "release-${{ steps.determine_number.outputs.release_number }}" --unreleased --strip all > release_notes.md
git-cliff --tag "release-${{ steps.determine_number.outputs.release_number }}" > CHANGELOG.md
- name: Push branch and create PR
run: |
git commit -am "Release ${{ steps.determine_number.outputs.release_number }}"
git push --set-upstream origin ${{ env.PR_BRANCH }}
gh pr create \
--base master \
--head ${{ env.PR_BRANCH }} \
--title "chore: Release ${{ steps.determine_number.outputs.release_number }} [skip-ci]" \
--body "Automated pull request - prepare release ${{ steps.determine_number.outputs.release_number }}"
- name: Merge PR
id: merge_pr
run: |
gh pr merge --squash --auto --delete-branch ${{ env.PR_BRANCH }}
echo sha=$( gh pr view --json mergeCommit ${{ env.PR_BRANCH }} | jq --raw-output .mergeCommit.oid ) >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: "release-${{ steps.determine_number.outputs.release_number }}"
name: "Release ${{ steps.determine_number.outputs.release_number }}"
target_commitish: ${{ steps.merge_pr.outputs.sha }}
body_path: release_notes.md
prepare_pkgbuild:
runs-on: ubuntu-latest
needs: gh_release
env:
TARBALL_URL: https://github.com/janbuchar/rorqual/archive/refs/tags/release-${{ needs.gh_release.outputs.release_number }}.tar.gz
RELEASE_NUMBER: ${{ needs.gh_release.outputs.release_number }}
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- name: Use cache
uses: actions/cache@v4
with:
path: out/
key: ${{ github.run_id }}
- name: Prepare output dir
run: mkdir -p out
- name: Create requirements.txt
run: |
poetry export -f requirements.txt --without-hashes --without dev -o out/requirements.txt
cat out/requirements.txt
- name: Copy launcher
run: cp aur/rorqual out/rorqual
- name: Create PKGBUILD
run: |
cat aur/PKGBUILD.template |
TARBALL_HASH=$(gh api $TARBALL_URL | sha256sum | cut -f 1 -d " ") \
REQUIREMENTS_HASH=$(sha256sum out/requirements.txt | cut -f 1 -d " ") \
LAUNCHER_HASH=$(sha256sum out/rorqual | cut -f 1 -d " ") \
envsubst '${TARBALL_URL} ${RELEASE_NUMBER} ${TARBALL_HASH} ${REQUIREMENTS_HASH} ${LAUNCHER_HASH}' > out/PKGBUILD
cat out/PKGBUILD
aur_push:
runs-on: ubuntu-latest
needs: prepare_pkgbuild
steps:
- name: Use cache
uses: actions/cache@v4
with:
path: out/
key: ${{ github.run_id }}
- name: Prepare output dir
run: mkdir -p out
- name: Setup AUR SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.AUR_PRIVATE_KEY }}
- name: Checkout AUR package
run: |
mkdir -p .ssh
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
git init
git remote add origin ssh://[email protected]/rorqual-venv.git
git pull origin master
- name: Apply changes
run: |
mv out/* ./
rm -rf out
- name: Prepare .SRCINFO
uses: heyhusen/[email protected]
with:
flags: ''
namcap: false
srcinfo: true
- name: Push to AUR
run: |
git config --global user.email "[email protected]"
git config --global user.name "Jan Buchar"
git add .
git commit -m "Release ${{ needs.gh_release.outputs.release_number }}"
git push origin master