forked from OpenCatalogi/opencatalogi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,27 +3,50 @@ name: Release Workflow | |
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to release (leave empty to use info.xml version)' | ||
required: false | ||
default: '' | ||
|
||
jobs: | ||
release-management: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set app env | ||
run: | | ||
# Split and keep last | ||
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV | ||
echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV | ||
# Step 1: Checkout the code | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} # Checkout the correct branch name | ||
fetch-depth: 0 # Fetch the whole repo history | ||
- name: Get current version and increment | ||
id: increment_version | ||
run: | | ||
current_version=$(grep -oP '(?<=<version>)[^<]+' appinfo/info.xml) | ||
IFS='.' read -ra version_parts <<< "$current_version" | ||
((version_parts[2]++)) | ||
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}" | ||
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV | ||
echo "new_version=$new_version" >> $GITHUB_OUTPUT | ||
- name: Update version in info.xml | ||
run: | | ||
sed -i "s|<version>.*</version>|<version>${{ env.NEW_VERSION }}</version>|" appinfo/info.xml | ||
# Step 2: Prepare the signing certificate and key | ||
- name: Commit version update | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git commit -am "Bump version to ${{ env.NEW_VERSION }}" | ||
git push | ||
# Step 1: Prepare the signing certificate and key | ||
- name: Prepare Signing Certificate and Key | ||
run: | | ||
echo "${{ secrets.NEXTCLOUD_SIGNING_CERT }}" > signing-cert.crt | ||
|
@@ -51,10 +74,10 @@ jobs: | |
# Step 7: Build composer dependencies | ||
- run: composer i --no-dev | ||
|
||
# Step 8: Copy the files into the package directory, excluding .git and package itself | ||
# Step 8: Copy the files into the package directory | ||
- name: Copy the package files into the package | ||
run: | | ||
mkdir -p package/opencatalogi | ||
mkdir -p package/${{ github.event.repository.name }} | ||
rsync -av --progress \ | ||
--exclude='package' \ | ||
--exclude='.git' \ | ||
|
@@ -90,17 +113,17 @@ jobs: | |
--exclude='stylelint.config.js' \ | ||
--exclude='.babelrc' \ | ||
--exclude='.nvmrc' \ | ||
./ package/opencatalogi/ | ||
./ package/${{ github.event.repository.name }}/ | ||
# Step 9: Create the TAR.GZ archive with code in opencatalogi directory | ||
# Step 9: Create the TAR.GZ archive | ||
- name: Create Tarball | ||
run: | | ||
cd package && tar -czf ../nexcloud-release.tar.gz opencatalogi | ||
cd package && tar -czf ../nextcloud-release.tar.gz ${{ github.event.repository.name }} | ||
# Step 10: Sign the TAR.GZ file with OpenSSL | ||
- name: Sign the TAR.GZ file with OpenSSL | ||
run: | | ||
openssl dgst -sha512 -sign signing-key.key nexcloud-release.tar.gz | openssl base64 -out nexcloud-release.signature | ||
openssl dgst -sha512 -sign signing-key.key nextcloud-release.tar.gz | openssl base64 -out nextcloud-release.signature | ||
# Step 11: Generate Git version information | ||
- name: Git Version | ||
|
@@ -118,52 +141,55 @@ jobs: | |
# Step 13: Run Changelog CI | ||
- name: Run Changelog CI | ||
if: github.ref == 'refs/heads/master' | ||
if: github.ref == 'refs/heads/main' | ||
uses: saadmk11/[email protected] | ||
with: | ||
release_version: ${{ steps.version.outputs.version }} | ||
release_version: ${{ env.NEW_VERSION }} | ||
config_file: changelog-ci-config.json | ||
|
||
# Step 14: Output the version | ||
- name: Use the version | ||
run: | | ||
echo ${{ steps.version.outputs.version }} | ||
# Step 15: Copy the files into the package directory, excluding .git and package itself | ||
# Step 15: Copy the package files into the package (this step seems redundant, consider removing) | ||
- name: Copy the package files into the package | ||
run: | | ||
mkdir -p package/opencatalogi | ||
rsync -av --progress --exclude='package' --exclude='.git' ./ package/opencatalogi/ | ||
mkdir -p package/${{ github.event.repository.name }} | ||
rsync -av --progress --exclude='package' --exclude='.git' ./ package/${{ github.event.repository.name }}/ | ||
# Step 18: Create a new release on GitHub | ||
- name: Upload Release | ||
uses: ncipollo/[email protected] | ||
with: | ||
artifacts: | | ||
LICENSE.md | ||
nexcloud-release.tar.gz | ||
nexcloud-release.signature | ||
opencatalogi-build.zip | ||
opencatalogi-build.tar.gz | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ steps.version.outputs.version }} | ||
tag: v${{ env.NEW_VERSION }} | ||
name: Release ${{ env.NEW_VERSION }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Attach tarball to github release | ||
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2 | ||
id: attach_to_release | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: nexcloud-release.tar.gz | ||
asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz | ||
tag: ${{ github.ref }} | ||
file: nextcloud-release.tar.gz # Corrected spelling | ||
asset_name: ${{ env.APP_NAME }}-${{ env.NEW_VERSION }}.tar.gz | ||
tag: v${{ env.NEW_VERSION }} | ||
overwrite: true | ||
|
||
- name: Upload app to Nextcloud appstore | ||
uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1 | ||
with: | ||
app_name: ${{ env.APP_NAME }} | ||
appstore_token: ${{ secrets.NEXTCLOUD_APPSTORE_TOKEN }} | ||
download_url: ${{ steps.attach_to_release.outputs.browser_download_url }} | ||
download_url: https://github.com/${{ github.repository }}/releases/download/v${{ env.NEW_VERSION }}/${{ env.APP_NAME }}-${{ env.NEW_VERSION }}.tar.gz | ||
app_private_key: ${{ secrets.NEXTCLOUD_SIGNING_KEY }} | ||
|
||
nightly: false | ||
|
||
- name: Verify version and contents | ||
run: | | ||
echo "App version: ${{ env.NEW_VERSION }}" | ||
echo "Tarball contents:" | ||
tar -tvf nextcloud-release.tar.gz | ||
echo "info.xml contents:" | ||
tar -xOf nextcloud-release.tar.gz ${{ env.APP_NAME }}/appinfo/info.xml |