Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 1f76e56

Browse files
authored
Adds a conditional action to build and push rpm and apt artifacts for pull requests to the dev repositories in nexus. (#169)
Adds build action to publish artifacts to the dev repo. Also changed nightly versions to be published to the dev repo instead of the nightly repo. For PRs the version number is changed before building by adding the pr number as a suffix. Suppress publishing of artifacts for runs that are triggered externally (dependabot mostly) as these do not have access to the necessary secret for deploying artifacts.
1 parent dc8d0c6 commit 1f76e56

File tree

2 files changed

+79
-46
lines changed

2 files changed

+79
-46
lines changed

.github/workflows/build_artifacts.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Publish-Artifacts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
REPO_APT_DEV_URL: https://repo.stackable.tech/repository/deb-dev
12+
REPO_RPM_DEV_URL: https://repo.stackable.tech/repository/rpm-dev
13+
14+
jobs:
15+
debian10:
16+
runs-on: debian10
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Change version if is PR
20+
if: ${{ github.event_name == 'pull_request' }}
21+
# We use "mr" instead of "pr" to denote pull request builds, as this prefix comes before "nightly" when lexically
22+
# sorting packages by version. This means that when installing the package without specifying a version the
23+
# nighly version is considered more current than mr versions and installed by default
24+
run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-mr${{ github.event.number }}"/' Cargo.toml
25+
- name: Build
26+
run: ~/.cargo/bin/cargo +nightly build --verbose --release
27+
- name: Build apt package
28+
run: ~/.cargo/bin/cargo deb --manifest-path Cargo.toml --no-build
29+
- name: Check workflow permissions
30+
id: check_permissions
31+
uses: scherermichael-oss/action-has-permission@1.0.6
32+
with:
33+
required-permission: write
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Publish apt package
37+
if: steps.check_permissions.outputs.has-permission
38+
run: >-
39+
/usr/bin/curl
40+
--fail
41+
-u 'github:${{ secrets.NEXUS_PASSWORD }}'
42+
-H "Content-Type: multipart/form-data"
43+
--data-binary "@./$(find target/debian/ -name *.deb)"
44+
"${{ env.REPO_APT_DEV_URL }}/"
45+
- name: Clean
46+
run: ~/.cargo/bin/cargo clean
47+
48+
centos:
49+
runs-on: centos${{ matrix.node }}
50+
strategy:
51+
matrix:
52+
node: [ 7, 8 ]
53+
steps:
54+
- uses: actions/checkout@v2
55+
- name: Change version if is PR
56+
if: ${{ github.event_name == 'pull_request' }}
57+
# We use "mr" instead of "pr" to denote pull request builds, as this prefix comes before "nightly" when lexically
58+
# sorting packages by version. This means that when installing the package without specifying a version the
59+
# nighly version is considered more current than mr versions and installed by default
60+
run: sed -i -e 's/^version = "\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/version = "\1-pr${{ github.event.number }}"/' Cargo.toml
61+
- name: Build
62+
run: ~/.cargo/bin/cargo +nightly build --verbose --release
63+
- name: Build RPM package
64+
run: packaging/buildrpm.sh stackable-agent
65+
- name: Check workflow permissions
66+
id: check_permissions
67+
uses: scherermichael-oss/action-has-permission@1.0.6
68+
with:
69+
required-permission: write
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
- name: Publish RPM package
73+
if: steps.check_permissions.outputs.has-permission
74+
run: >-
75+
/usr/bin/curl
76+
--fail
77+
-u 'github:${{ secrets.NEXUS_PASSWORD }}'
78+
--upload-file "./$(find target/rpm/RPMS/x86_64/ -name *.rpm)"
79+
"${{ env.REPO_RPM_DEV_URL }}/el${{ matrix.node }}/"

.github/workflows/nightly.yml

-46
This file was deleted.

0 commit comments

Comments
 (0)