forked from flatpak/xdg-desktop-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (88 loc) · 3.1 KB
/
release.yml
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Release new version
on:
workflow_dispatch:
inputs:
version:
description: "Release version (MAJOR.MINOR.PATCH, default: extracted from NEWS)"
preRelease:
description: "Is this a pre-release? (true/false, default: true if release version minor number is odd)"
dryRun:
description: "Dry Run (true/false, default: true)"
default: true
jobs:
build-container:
uses: ./.github/workflows/container.yml
permissions:
packages: write
release:
name: Build and publish a release
runs-on: ubuntu-latest
needs: build-container
permissions:
contents: write
container:
image: ${{ needs.build-container.outputs.image }}
options: ${{ needs.build-container.outputs.image_options }}
steps:
- name: Configure git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Checkout the repository
uses: actions/checkout@v4
- name: Update translation files
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
run: |
meson setup . _build
meson compile -C _build/ xdg-desktop-portal-update-po
git add po/*po
git commit -m "Update po files"
git push
git clean -fxd
- name: Build xdg-desktop-portal
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
run: |
meson setup . _build
meson dist -C _build
- name: Extract release information
env:
releaseVersion: ${{ github.event.inputs.version }}
preRelease: ${{ github.event.inputs.preRelease }}
run: |
# Extract the release version
if [ -z $releaseVersion ]; then
releaseVersion=`perl -0777nE 'print $& if /(?<=Changes in ).*/' NEWS`
fi
echo "releaseVersion=$releaseVersion" | tee -a $GITHUB_ENV
# Extract the changelog
{
echo "releaseChangelog<<EOF"
perl -0777nE 'print $& if /(?<=\n\n).*?(?=\n\n)/sg' NEWS
echo "\nEOF"
} | tee -a $GITHUB_ENV
# Check if version is a pre-release
if [ -z $preRelease ]; then
preRelease=$((`echo $releaseVersion | cut -d '.' -f2` % 2))
fi
{
echo -n "preRelease="
if [ $preRelease = 1 ] || [ $preRelease = "true" ]; then
echo "true";
else
echo "false";
fi
} | tee -a $GITHUB_ENV
- name: Tag release
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
run: |
git tag $releaseVersion
git push --tags
- name: Create release
if: ${{ !fromJSON(github.event.inputs.dryRun) }}
uses: ncipollo/[email protected]
with:
tag: ${{ env.releaseVersion }}
body: ${{ env.releaseChangelog }}
prerelease: ${{ env.preRelease }}
artifacts: _build/meson-dist/*