Release/0.0.2 #74
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: RPM Build and Upload | |
on: | |
pull_request: | |
branches: | |
- 'main' | |
- 'master' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
ref: | |
- name: Check Branch and Target | |
if: > | |
github.event_name == 'pull_request' && | |
(github.event.action == 'opened' || github.event.action == 'synchronize') && | |
startsWith(github.event.pull_request.head.ref, 'release/') && | |
(github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main') | |
run: echo "Running the workflow for branch ${GITHUB_HEAD_REF} to ${GITHUB_BASE_REF}" || (echo "Skipping workflow as the conditions are not met." && exit 0) | |
- name: Create tag | |
run: | | |
git fetch --all --tags | |
tag_name="${{ env.VERSION }}" | |
if ! git rev-parse -q --verify "refs/tags/$tag_name" >/dev/null; then | |
git tag $tag | |
fi | |
env: | |
DEFAULT_BRANCH: ${{ env.DEFAULT_BRANCH }} | |
- name: Set Version & pull tag | |
id: version | |
run: | | |
VERSION=$(echo ${{ github.head_ref }} | sed 's/release\///') | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Comment version BUMP | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const version = process.env.VERSION; | |
if (!version) { | |
core.setFailed('Error: VERSION environment variable is not set.'); | |
} | |
const commentBody = `Version ${version} is going to be the next version release :), wait for RPM and then complete the merge :tada:`; | |
const { data: comment } = await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentBody, | |
}); | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VERSION: ${{ env.VERSION }} | |
- name: Run Docker Container | |
run: docker run --privileged -d --name builder --network host rockylinux:9 /bin/sleep infinity | |
- name: Install build tools RPM | |
run: | | |
docker cp ./ builder:/build | |
docker exec builder bash -c "yum install -y epel-release && yum install -y make git mock" | |
docker exec builder bash -c "rm -rf /etc/mock/default.cfg" | |
- name: Setup SDK | |
run: | | |
docker exec builder bash -c "curl https://raw.githubusercontent.com/redBorder/repoinit/master/sdk9.cfg > /build/sdk9.cfg" | |
docker exec builder bash -c "echo \"config_opts['use_host_resolv'] = True\" >> /build/sdk9.cfg" | |
docker exec builder bash -c "ln -s /build/sdk9.cfg /etc/mock/default.cfg" | |
- name: Build RPM using mock | |
run: | | |
docker exec builder bash -c "git config --global --add safe.directory /build" | |
docker exec builder bash -c "cd /build/ && VERSION=${VERSION} make rpm" | |
env: | |
VERSION: ${{ env.VERSION }} | |
- name: Copy RPMS | |
run: | | |
docker cp builder:/build/packaging/rpm/pkgs/. ./rpms | |
- name: Delete not .rpm files | |
run: | | |
find ./rpms -type f -not -name '*.rpm' -exec rm {} \; | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ./rpms/* | |
tag_name: ${{ env.VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |