-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
84 lines (79 loc) · 2.67 KB
/
Copy pathaction.yaml
File metadata and controls
84 lines (79 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Build nFPM packages
description: Build linux packages using nFPM
inputs:
packager:
description: Target package types, deb, rpm, etc.
required: false
default: deb
type: string
config:
description: Path to nFPM config file
type: string
target:
description: Where to save generated package
type: string
default: dist
fallback-version:
description: Version to fall back to if no tag can be found
type: string
checkout:
description: Whether to perform action/checkout
default: true
setup-nfpm:
description: Whether to set up nfpm
default: true
tag-prefix:
description: Prefix that identifies a tag as a version tag
default: v
runs:
using: composite
steps:
- uses: actions/checkout@v7
if: ${{ fromJSON(inputs.checkout) }}
with:
# Get all the history so we can detect which is the previous tag.
fetch-depth: 0
- uses: secondlife/setup-nfpm@v5
if: ${{ fromJSON(inputs.setup-nfpm) }}
- uses: secondlife-3p/github-action-get-previous-tag@v2
id: previous-tag
with:
fallback: ${{ inputs.fallback-version }}
pattern: "${{ inputs.tag-prefix }}*"
- name: Determine next version
id: version
shell: bash
env:
PREV: ${{ steps.previous-tag.outputs.tag }}
TAG_PREFIX: ${{ inputs.tag-prefix }}
run: |
if [[ "$GITHUB_REF" == refs/tags/"$TAG_PREFIX"* ]]; then
tag_version="${GITHUB_REF#refs/tags/"$TAG_PREFIX"}"
else
# Add an abbreviated commit to the version to indicate this is a
# "prerelease" of the previous tag... which really it isn't, it's a
# prerelease of the next release. If the identified previous tag
# already has a prerelease portion (`-` in a semantic version), this
# *will* get two prerelease sections, but that's OK.
tag_version="${PREV#"$TAG_PREFIX"}~$(git rev-parse --short HEAD)"
fi
# The git tag is a semantic version, where `-` indicates a prerelease
# version. Debian & RPM packages use `~` to indicate prerelease
# versions. So translate `-`s into `~`s.
tag_version="${tag_version//-/\~}"
echo "value=$tag_version" >> $GITHUB_OUTPUT
- name: Build deb
shell: bash
env:
VERSION: ${{ steps.version.outputs.value }}
TARGET: ${{ inputs.target }}
CONFIG: ${{ inputs.config }}
PACKAGER: ${{ inputs.packager }}
run: |
if [[ ! -z "$TARGET" ]]; then
mkdir -p "$TARGET"
fi
nfpm package \
${CONFIG:+--config "$CONFIG"} \
${TARGET:+--target "$TARGET"} \
--packager $PACKAGER