Skip to content

Commit a3071d0

Browse files
committed
🤖 Fedora Copr release pipeline
Signed-off-by: Marc Nuri <[email protected]>
1 parent f620084 commit a3071d0

File tree

4 files changed

+61
-9
lines changed

4 files changed

+61
-9
lines changed

.github/workflows/publish-copr.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2023 Marc Nuri San Felix
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: Publish Copr (Fedora)
15+
16+
on:
17+
workflow_dispatch:
18+
inputs:
19+
version:
20+
description: 'Version to publish'
21+
required: true
22+
default: 'v0.0.0'
23+
# TODO: enable once completely tested
24+
# push:
25+
# tags:
26+
# - '*'
27+
28+
jobs:
29+
copr:
30+
name: Copr Publish
31+
runs-on: ubuntu-latest
32+
env:
33+
COPR_API_KEY: ${{ secrets.COPR_API_KEY }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
- name: Set API key
38+
run: echo "${COPR_API_KEY}" > ~/.config/copr
39+
- name: Install copr-cli
40+
run: pip install copr-cli
41+
- name: Version from dispatch inputs
42+
if: github.event_name == 'workflow_dispatch'
43+
run: echo "WORKFLOW_DISPATCH_GITHUB_REF=refs/tags/${{ inputs.version }}" >> $GITHUB_ENV
44+
- name: Change build-config/electronim.spec version
45+
run: ./utils/version-from-tag.js
46+
- name: Publish
47+
run: |
48+
copr-cli build manusa/electronim build-config/electronim.spec --enable-net on

build-config/electronim.spec

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
%global debug_package %{nil}
55

66
Name: electronim
7-
# TODO v---- Automate -- Try to use copr-cli from GitHub Actions upon release `copt-cli build build-config/electronim.spec #...`
8-
Version: 0.0.89
7+
Version: 0.0.0
98
Release: 0%{?dist}
109
Summary: Electron based multi IM (Instant Messaging) client
1110
License: Apache-2.0
1211
Url: https://github.com/manusa/electronim
1312
# Tag sources
1413
Source0: %{url}/archive/refs/tags/v%{version}.zip
15-
# Desktop file (TODO: not needed once it's available as part of the tag)
16-
Source1: build-config/%{pkg_name}.desktop
1714

1815
BuildRequires: python3-devel
1916
BuildRequires: gcc-c++
@@ -53,8 +50,7 @@ ln -sf %{_optpkgdir}/electronim %{buildroot}%{_bindir}/electronim
5350

5451
# install desktop file
5552
install -dp %{buildroot}%{_datadir}/applications
56-
# TODO: once Source1 is removed, replace with the specific desktop file
57-
install -Dp -m0755 %{SOURCE1} %{buildroot}%{_datadir}/applications
53+
install -Dp -m0755 build-config/electronim.desktop %{buildroot}%{_datadir}/applications
5854

5955

6056
#-- FILES ---------------------------------------------------------------------#

utils/common.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const refPrefix = 'refs/tags/v';
22

33
const extractVersionFromTag = () => {
4-
const githubRef = process.env.GITHUB_REF;
5-
if (githubRef && githubRef.startsWith(refPrefix)) {
6-
return githubRef.replace(refPrefix, '');
4+
for (const githubRef of [process.env.GITHUB_REF, process.env.WORKFLOW_DISPATCH_GITHUB_REF]) {
5+
if (githubRef && githubRef.startsWith(refPrefix)) {
6+
return githubRef.replace(refPrefix, '');
7+
}
78
}
89
return null;
910
};

utils/version-from-tag.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/* eslint-disable no-console */
33

44
const childProcess = require('child_process');
5+
const fs = require('fs');
6+
const path = require('path');
57
const errorHandler = require('./error-handler');
68
const {extractVersionFromTag} = require('./common');
79

@@ -16,6 +18,11 @@ const versionFromTag = () => {
1618
env: {...process.env},
1719
stdio: 'inherit'
1820
});
21+
console.log(`Setting electronim.spec version to ${version}`);
22+
const electronimSpec = path.resolve(__dirname, '..', 'build-config', 'electronim.spec');
23+
fs.writeFileSync(electronimSpec, fs.readFileSync(electronimSpec).toString()
24+
.replace(/Version.+$/gm, `Version: ${version}`)
25+
);
1926
process.exit(0);
2027
};
2128

0 commit comments

Comments
 (0)