Skip to content

Commit 40dcb28

Browse files
committed
github: update build actions
1 parent 7f6f1bc commit 40dcb28

3 files changed

Lines changed: 65 additions & 34 deletions

File tree

.github/workflows/build-deb.yaml

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,13 @@
11
name: Build and Publish Debian Package
22

33
on:
4-
push:
5-
branches:
6-
- '**'
7-
tags:
8-
- '**'
9-
pull_request:
10-
branches:
11-
- '**'
4+
workflow_call:
125

136
jobs:
14-
create_release:
15-
if: startsWith(github.ref, 'refs/tags/')
16-
runs-on: ubuntu-latest
17-
outputs:
18-
upload_url: ${{ steps.create_release.outputs.upload_url }}
19-
steps:
20-
- uses: actions/checkout@v3
21-
22-
- id: create_release
23-
uses: actions/create-release@v1
24-
env:
25-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26-
with:
27-
tag_name: ${{ github.ref_name }}
28-
release_name: Release ${{ github.ref_name }}
29-
body: Automated release for tag ${{ github.ref_name }}
30-
draft: false
31-
prerelease: false
32-
337
build-deb:
348
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
3511
env:
3612
DEB_BUILD_OPTIONS: "compress=gzip nocheck"
3713
PKGNAME: "libethercat"
@@ -70,7 +46,7 @@ jobs:
7046
apt-get install -y libosal-dev
7147
7248
- name: Checkout source
73-
uses: actions/checkout@v4
49+
uses: actions/checkout@v6
7450
with:
7551
fetch-depth: 0
7652

@@ -98,11 +74,16 @@ jobs:
9874
else
9975
if [[ ! $GITHUB_REF =~ ^refs/tags/ ]]; then
10076
# Not a tag, so add ~pre<x>
101-
FULL_VERSION="${VERSION}~${PRE_VERSION}-1~${CODENAME}-pre"
77+
FULL_VERSION="${VERSION}~${PRE_VERSION}~${CODENAME}-pre"
10278
dch -b --newversion "${FULL_VERSION}" --distribution "${CODENAME}-pre" "Pre-release for ${CODENAME}-pre"
10379
else
104-
FULL_VERSION="${VERSION}-1~${CODENAME}"
105-
dch --newversion "${FULL_VERSION}" --distribution "${CODENAME}" "Pre-release for ${CODENAME}"
80+
FULL_VERSION="${VERSION}~${CODENAME}"
81+
if echo "${GITHUB_REF_NAME}" | grep -q "\-rev"; then
82+
REVISION=$(echo "${GITHUB_REF_NAME}" | sed -n 's/.*-rev\([0-9]*\)$/\1/p')
83+
echo "Revision found: $REVISION"
84+
FULL_VERSION="${VERSION}-${REVISION}~${CODENAME}"
85+
fi
86+
dch -b --newversion "${FULL_VERSION}" --distribution "${CODENAME}" "Pre-release for ${CODENAME}"
10687
fi
10788
fi
10889
@@ -129,15 +110,17 @@ jobs:
129110
if [[ "$DISTRO" == "ubuntu-24.04" || "$DISTRO" == "ubuntu-22.04" ]]; then
130111
OLD_EXT=".ddeb"
131112
NEW_EXT=".deb"
113+
CHANGES_FILE="${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
132114
133115
OLD_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${OLD_EXT}"
134116
NEW_FILE="${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64${NEW_EXT}"
135-
CHANGES_FILE="${PKGNAME}_${SANITIZED_IMAGE}_amd64.changes"
136117
137118
mv "../$OLD_FILE" "../$NEW_FILE"
138119
sed -i "s/${OLD_FILE}/${NEW_FILE}/g" "../$CHANGES_FILE"
139120
fi
140121
122+
ls -l ../
123+
141124
DBG_FILE="../${PKGNAME}-dbgsym_${SANITIZED_IMAGE}_amd64.deb"
142125
DEV_FILE="../${PKGNAME}-dev_${SANITIZED_IMAGE}_amd64.deb"
143126
DEB_FILE="../${PKGNAME}_${SANITIZED_IMAGE}_amd64.deb"
@@ -163,10 +146,10 @@ jobs:
163146
- name: Collect .deb artifact
164147
run: |
165148
mkdir -p artifacts/
166-
rsync -av --exclude=${PKGNAME} ../ artifacts/
149+
rsync -av --include="*.deb" --include="*.changes" --include="*.buildinfo" --include="*.dsc" --include="*.tar.gz" --exclude="*" ../ artifacts/
167150
168151
- name: Upload .deb package artifact
169-
uses: actions/upload-artifact@v4
152+
uses: actions/upload-artifact@v7
170153
with:
171154
name: ${{ env.PKGNAME }}-artifacts-${{ steps.sanitize.outputs.sanitized_image }}
172155
path: artifacts/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Trigger On Master
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
run-shared:
12+
uses: ./.github/workflows/build-deb.yaml
13+
secrets: inherit
14+

.github/workflows/trigger-tag.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Trigger On Tag
2+
on:
3+
push:
4+
tags:
5+
- '**'
6+
workflow_dispatch:
7+
inputs:
8+
tag_name:
9+
description: 'Tag name to process'
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
create_release:
18+
if: startsWith(github.ref, 'refs/tags/')
19+
runs-on: ubuntu-latest
20+
outputs:
21+
upload_url: ${{ steps.create_release.outputs.upload_url }}
22+
steps:
23+
- id: create_release
24+
uses: ncipollo/release-action@v1
25+
with:
26+
tag: ${{ github.ref_name }}
27+
name: Release ${{ github.ref_name }}
28+
body: Automated release for tag ${{ github.ref_name }}
29+
draft: false
30+
prerelease: false
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
run-shared:
33+
uses: ./.github/workflows/build-deb.yaml
34+
secrets: inherit

0 commit comments

Comments
 (0)