Skip to content

Commit b393c52

Browse files
author
Naveenraj M
committed
Update README
1 parent ca2383e commit b393c52

File tree

1 file changed

+99
-9
lines changed

1 file changed

+99
-9
lines changed

README.md

Lines changed: 99 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ Integrates easily with GitHub actions to allow RPMS to be uploaded as Artifact (
88
### Pre-requisites
99
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow---build-rpm) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
1010

11-
This generated RPMS and SRPMS can be used in two ways.
12-
1. Upload as build artifact
13-
You can use GitHub Action [`@actions/upload-artifact`](https://www.github.com/actions/upload-artifact)
14-
2. Upload as Release assest
15-
If you want to upload as release asset ,You also will need to have a release to upload your asset to, which could be created programmatically by [`@actions/create-release`](https://www.github.com/actions/create-release) as show in the example workflow.
11+
**Note:** You need to have a spec file in order to build RPM.
12+
1613

1714
### Inputs
1815

19-
- `spec_file`: The path to the spec file in your repo. `**require**`
16+
- `spec_file`: The path to the spec file in your repo. [**required**]
2017

2118
### Outputs
2219

@@ -26,6 +23,11 @@ This generated RPMS and SRPMS can be used in two ways.
2623
- `source_rpm_name`: name of Source RPM file
2724
- `rpm_content_type`: Content-type for RPM Upload
2825

26+
This generated RPMS and SRPMS can be used in two ways.
27+
1. Upload as build artifact
28+
You can use GitHub Action [`@actions/upload-artifact`](https://www.github.com/actions/upload-artifact)
29+
2. Upload as Release assest
30+
If you want to upload as release asset ,You also will need to have a release to upload your asset to, which could be created programmatically by [`@actions/create-release`](https://www.github.com/actions/create-release) as show in the example workflow.
2931

3032
### Example workflow - build RPM
3133

@@ -49,10 +51,98 @@ jobs:
4951
- name: Upload artifact
5052
uses: actions/[email protected]
5153
with:
52-
name: Source RPM
53-
path: ${{ steps.rpm.outputs.source_rpm_path }}
54+
name: Binary RPM
55+
path: ${{ steps.rpm.outputs.rpm_dir_path }}
5456
```
57+
This workflow triggered on every `push` , builds RPM and Source RPM using cello.spec and contents of that git ref that triggered that action. Contents are retrived through [GitHub API](https://developer.github.com/v3/repos/contents/#get-archive-link) [downloaded through archive link].
58+
The generated RPMs or SRPMS can be uploaded as artifacts by using actions/upload-artifact. The [outputs](#outputs) given by rpmbuild action can be used to specify path for upload action.
59+
60+
#### Above workflow will create an artifact like :
61+
62+
[artifact_image](!assests/upload_artifacts.png)
63+
<img src="assests/upload_artifacts.png" alt>
64+
65+
Use with Release:
66+
```yaml
67+
on:
68+
push:
69+
# Sequence of patterns matched against refs/tags
70+
tags:
71+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
72+
73+
name: Create RPM Release
74+
75+
jobs:
76+
build:
77+
name: Create RPM Release
78+
runs-on: ubuntu-latest
79+
80+
steps:
81+
82+
- name: Checkout code
83+
uses: actions/checkout@master
84+
85+
- name: Create Release
86+
id: create_release
87+
uses: actions/create-release@latest
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
90+
with:
91+
tag_name: ${{ github.ref }}
92+
release_name: Release ${{ github.ref }}
93+
body: |
94+
Changes in this Release
95+
- Create RPM
96+
- Upload Source RPM
97+
draft: false
98+
prerelease: false
99+
100+
- name: build RPM package
101+
id: rpm_build
102+
uses: naveenrajm7/rpmbuild@master
103+
with:
104+
spec_file: "cello.spec"
105+
106+
- name: Upload Release Asset
107+
id: upload-release-asset
108+
uses: actions/upload-release-asset@v1
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
with:
112+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
113+
asset_path: ${{ steps.rpm_build.outputs.source_rpm_path }}
114+
asset_name: ${{ steps.rpm_build.outputs.source_rpm_name }}
115+
asset_content_type: ${{ steps.rpm_build.outputs.rpm_content_type }}
116+
```
117+
118+
#### The above release uploads SRPM like :
119+
120+
[artifact_image](!assests/upload_release_asset.png)
121+
<img src="assests/upload_release_asset.png" alt>
122+
123+
Example Repository which uses rpmbuild action https://github.com/naveenrajm7/cello
124+
125+
Note on distribution:
126+
If your RPMs are distribution specific like el7 or el8.
127+
- Use naveenrajm7/rpmbuild@master for Centos7 *[el7]*
128+
- Use naveenrajm7/rpmbuild@centos8 for Centos8 *[el8]*
129+
130+
```yaml
131+
- name: build RPM package
132+
id: rpm_build
133+
uses: naveenrajm7/rpmbuild@centos8
134+
with:
135+
spec_file: "cello.spec"
136+
```
137+
138+
## References
139+
140+
* [RPM Packaging Guide](https://rpm-packaging-guide.github.io/)
141+
* [GitHub Learning Lab](https://lab.github.com/)
142+
* [Container Toolkit Action](https://github.com/actions/container-toolkit-action)
55143
56144
## License
57145
58-
The scripts and documentation in this project are released under the [GNU GPLv3](LICENSE)
146+
The scripts and documentation in this project are released under the [GNU GPLv3](LICENSE)
147+
148+
*Created during the GitHub Actions Hackathon 2020 :octocat: :computer: .*

0 commit comments

Comments
 (0)