diff --git a/.gitea/workflows/build-publish-rpm.yaml b/.gitea/workflows/build-publish-rpm.yaml index 4979efc..8efeed1 100644 --- a/.gitea/workflows/build-publish-rpm.yaml +++ b/.gitea/workflows/build-publish-rpm.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - 'v*' jobs: build-and-publish: @@ -17,16 +19,16 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Create build directory + - name: Setup RPM build environment run: | - mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} + mkdir -p ~/rpmbuild/{SOURCES,SPECS,BUILD,RPMS,SRPMS} echo "%_topdir %(echo $HOME)/rpmbuild" > ~/.rpmmacros - name: Create source archive run: | tar -czf hello-0.0.1.tar.gz hello.sh - - name: Copy spec file + - name: Copy spec file and source run: | cp hello.spec ~/rpmbuild/SPECS/ cp hello-0.0.1.tar.gz ~/rpmbuild/SOURCES/ @@ -36,47 +38,47 @@ jobs: cd ~/rpmbuild rpmbuild -ba SPECS/hello.spec -# - name: Publish RPM to Gitea -# run: | -# # Extract version from spec file -# VERSION=$(grep -E "^Version:" hello.spec | cut -d: -f2 | xargs) -# echo "Version: $VERSION" -# -# # Find built RPM -# RPM_FILE=$(find ~/rpmbuild -name "*.rpm" -type f | head -1) -# echo "RPM file: $RPM_FILE" -# -# # Publish to Gitea -# if [ -n "$GITEA_TOKEN" ] && [ -n "$GITEA_OWNER" ]; then -# curl -u "$GITEA_OWNER:$GITEA_TOKEN" \ -# --upload-file "$RPM_FILE" \ -# "https://gitea.example.com/api/packages/$GITEA_OWNER/rpm/upload" -# else -# echo "Missing GITEA_TOKEN or GITEA_OWNER environment variables" -# exit 1 -# fi -# -# - name: Publish RPM with group -# if: ${{ contains(github.ref, 'v') }} -# run: | -# # Extract version from spec file -# VERSION=$(grep -E "^Version:" hello.spec | cut -d: -f2 | xargs) -# echo "Version: $VERSION" -# -# # Find built RPM -# RPM_FILE=$(find ~/rpmbuild -name "*.rpm" -type f | head -1) -# echo "RPM file: $RPM_FILE" -# -# # Publish to Gitea with group (using tag name as group) -# TAG_NAME=${GITHUB_REF#refs/tags/} -# echo "Publishing to group: $TAG_NAME" -# -# if [ -n "$GITEA_TOKEN" ] && [ -n "$GITEA_OWNER" ]; then -# curl -u "$GITEA_OWNER:$GITEA_TOKEN" \ -# --upload-file "$RPM_FILE" \ -# "https://gitea.example.com/api/packages/$GITEA_OWNER/rpm/$TAG_NAME/upload" -# else -# echo "Missing GITEA_TOKEN or GITEA_OWNER environment variables" -# exit 1 -# fi -# \ No newline at end of file + - name: Publish RPM to Gitea + if: github.ref_type == 'tag' + run: | + # Extract version from spec file + VERSION=$(grep -E "^Version:" hello.spec | cut -d: -f2 | xargs) + echo "Version: $VERSION" + + # Find built RPM + RPM_FILE=$(find ~/rpmbuild -name "*.rpm" -type f | head -1) + echo "RPM file: $RPM_FILE" + + # Publish to Gitea + if [ -n "$GITEA_TOKEN" ] && [ -n "$GITEA_OWNER" ]; then + curl -u "$GITEA_OWNER:$GITEA_TOKEN" \ + --upload-file "$RPM_FILE" \ + "https://gitea.example.com/api/packages/$GITEA_OWNER/rpm/upload" + else + echo "Missing GITEA_TOKEN or GITEA_OWNER environment variables" + exit 1 + fi + + - name: Publish RPM with group + if: github.ref_type == 'tag' + run: | + # Extract version from spec file + VERSION=$(grep -E "^Version:" hello.spec | cut -d: -f2 | xargs) + echo "Version: $VERSION" + + # Find built RPM + RPM_FILE=$(find ~/rpmbuild -name "*.rpm" -type f | head -1) + echo "RPM file: $RPM_FILE" + + # Publish to Gitea with group (using tag name as group) + TAG_NAME=${GITHUB_REF#refs/tags/} + echo "Publishing to group: $TAG_NAME" + + if [ -n "$GITEA_TOKEN" ] && [ -n "$GITEA_OWNER" ]; then + curl -u "$GITEA_OWNER:$GITEA_TOKEN" \ + --upload-file "$RPM_FILE" \ + "https://gitea.example.com/api/packages/$GITEA_OWNER/rpm/$TAG_NAME/upload" + else + echo "Missing GITEA_TOKEN or GITEA_OWNER environment variables" + exit 1 + fi diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b0ac3ed --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.aider*