Skip to content

Commit

Permalink
Fix release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tokox committed Mar 19, 2024
1 parent 682f407 commit d8d3f9f
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Release
run-name: Release ${{ github.ref }}
run-name: Release ${{ github.ref_name }}

on:
push:
Expand All @@ -16,20 +16,25 @@ jobs:
container: fedora:latest

steps:
- name: Install dnf-copr and copr-cli
run: dnf install -y dnf-plugins-core copr-cli
- name: Install copr-cli
run: dnf install -y copr-cli

- name: Setup copr-cli
run: |
mkdir -p ~/.config/copr
mkdir -p ~/.config
echo "[copr-cli]" > ~/.config/copr
echo "login = ${{ secrets.COPR_LOGIN }}" >> ~/.config/copr
echo "username = tokox" >> ~/.config/copr
echo "token = ${{ secrets.COPR_TOKEN }}" >> ~/.config/copr
echo "copr_url = https://copr.fedorainfracloud.org" >> ~/.config/copr
- name: Build package
run: copr-cli buildscm --clone-url "${{ github.repository }}" --commit "${{ github.ref }}" tokox/cpp-json --timeout 1800
run: |
url="${{ github.repositoryUrl }}"
if [[ $url == git://* ]]; then
url="https://${url:6}"
fi
copr-cli buildscm --clone-url "$url" --commit "${{ github.ref_name }}" ${{ github.repository }} --timeout 1800
make_release:
Expand All @@ -39,34 +44,40 @@ jobs:
needs: [copr_build]

steps:
- name: Install git
run: dnf install -y git && dnf upgrade -y git

- name: Checkout code
uses: actions/[email protected]

- name: Get previous tag
id: get_previous_tag
uses: jossef/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
uses: pozetroninc/[email protected]
with:
repository: ${{ github.repository }}
token: ${{ github.token }}

- name: Move vlatest to ${{ github.ref }}
- name: Move vlatest to ${{ github.ref_name }}
uses: rickstaa/[email protected]
with:
tag: vlatest
force_push_tag: true
commit_sha: ${{ github.sha }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Create changelog from spec file
run: |
echo "**Changelog**" > changelog.md
sed -n '/%changelog/,$p' cpp-json.spec | tail -n +2 | awk '/\*/{if (found++ == 1) exit} 1' >> changelog.md
echo "**Full Changelog**: https://github.com/tokox/cpp-json/compare/${{ steps.get_previous_tag.outputs.tag_name }}...${{ github.ref }}" >> changelog.md
echo "**Full Changelog**: https://github.com/tokox/cpp-json/compare/${{ steps.get_previous_tag.outputs.release }}...${{ github.ref_name }}" >> changelog.md
- name: Create release
uses: ncipollo/[email protected]
with:
name: Release ${{ github.ref }}
name: Release ${{ github.ref_name }}
bodyFile: changelog.md
tag: ${{ github.ref }}
tag: ${{ github.ref_name }}


upload_assets:
Expand All @@ -76,12 +87,12 @@ jobs:
needs: [make_release, copr_build]

steps:
- name: Install dnf-copr and copr-cli
run: dnf install -y dnf-plugins-core copr-cli
- name: Install copr-cli
run: dnf install -y copr-cli

- name: Setup copr-cli
run: |
mkdir -p ~/.config/copr
mkdir -p ~/.config
echo "[copr-cli]" > ~/.config/copr
echo "login = ${{ secrets.COPR_LOGIN }}" >> ~/.config/copr
echo "username = tokox" >> ~/.config/copr
Expand All @@ -90,17 +101,23 @@ jobs:
- name: Get copr build id
id: get_copr_build_id
run: echo "id=$(copr-cli list-builds --output-format text-row tokox/cpp-json | grep 'tokox-cpp-json' | grep 'succeeded' | awk '{print $1; exit}') >> $GITHUB_OUTPUT
run: echo "id=$(copr-cli list-builds --output-format text-row tokox/cpp-json | grep 'tokox-cpp-json' | grep 'succeeded' | awk '{print $1; exit}')" >> $GITHUB_OUTPUT

- name: Download assets
run: copr-cli download --output-dir assets tokox/cpp-json ${{ steps.get_copr_build_id.outputs.id }}
run: copr-cli download-build --dest assets --rpms ${{ steps.get_copr_build_id.outputs.id }}

- name: Rename assets
run: |
for file in assets/*/*.rpm; do
mv $file assets/$(basename $(dirname $file | sed 's/-x86_64$//'))_$(basename $file)
done
- name: Upload assets
uses: ncipollo/[email protected]
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: assets/**
artifacts: assets/*.rpm
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
tag: ${{ github.ref }}
tag: ${{ github.ref_name }}

0 comments on commit d8d3f9f

Please sign in to comment.