Skip to content

Commit

Permalink
ci(release): make release scripts more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
msavy committed Nov 29, 2022
1 parent d25aa1b commit f87f7c0
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 129 deletions.
246 changes: 118 additions & 128 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,198 +17,184 @@ jobs:
release:
runs-on: ubuntu-latest
if: github.repository_owner == 'Apiman'
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
DEV_VERSION: ${{ github.event.inputs.snapshot-version }}
steps:
- name: Set up Node.js v14
uses: actions/setup-node@v1
- name: Set global git
run: |
git config --global user.name "apiman-ci"
git config --global user.email "ci.apiman@gmail.com"
# Checkout all repositories we're going to use for the release
- name: Check out Apiman
uses: actions/checkout@v3
with:
repository: apiman/apiman
ref: master
path: 'apiman'
lfs: true
submodules: false
token: ${{ secrets.ACCESS_TOKEN }}

- name: Submodule manual step
run: |
cd apiman
git submodule update --init --force --recursive
git submodule set-branch --branch various-work-for-release -- portal/ui
- name: Check out Apiman Plugins
uses: actions/checkout@v3
with:
repository: apiman/apiman-plugins
ref: master
path: 'plugins'
token: ${{ secrets.ACCESS_TOKEN }}

- name: Check out Default API Catalog Code
uses: actions/checkout@v3
with:
repository: apiman/apiman-api-catalog
ref: master
path: 'apiman-api-catalog'
token: ${{ secrets.ACCESS_TOKEN }}

- name: Check out Default Plugin Registry
uses: actions/checkout@v3
with:
node-version: 14
repository: apiman/apiman-plugin-registry
ref: master
path: 'apiman-plugin-registry'
token: ${{ secrets.ACCESS_TOKEN }}

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Set up Gren
run: npm install github-release-notes -g

- name: Set up NPM CLI Login
run: npm install -g npm-cli-login
cache: 'maven'
server-id: 'ossrh'
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v1
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

- name: Set up settings.xml
run: |
mkdir -p /home/runner/.m2
chmod 755 /home/runner/.m2
echo "<settings><servers><server><id>${{ secrets.OSSRH_ID }}</id><username>${{ secrets.OSSRH_USERNAME }}</username><password>${{ secrets.OSSRH_TOKEN }}</password></server></servers><profiles><profile><id>${{ secrets.OSSRH_ID }}</id><activation><activeByDefault>true</activeByDefault></activation><properties><gpg.executable>gpg</gpg.executable><gpg.passphrase>${{ secrets.GPG_PASSPHRASE}}</gpg.passphrase></properties></profile></profiles></settings>" > /home/runner/.m2/settings.xml
cat /home/runner/.m2/settings.xml
# Checkout all repositories we're going to use for the release
- name: Apiman Code Checkout
run: |
mkdir apiman
cd apiman
git init
git config --global user.name "apiman-ci"
git config --global user.email "ci.apiman@gmail.com"
git remote add origin "https://apiman-ci:${{ secrets.ACCESS_TOKEN }}@github.com/$GITHUB_REPOSITORY.git"
git fetch --recurse-submodules
git checkout master
git branch --set-upstream-to=origin/master
git pull
git submodule update --init --recursive
- name: Apiman Website Code Checkout
run: |
mkdir website
cd website
git init
git remote add origin "https://apiman-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apiman/apiman.github.io.git"
git fetch
git checkout master
git branch --set-upstream-to=origin/master
git pull
- name: Apiman Plugins Code Checkout
run: |
mkdir plugins
cd plugins
git init
git remote add origin "https://apiman-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apiman/apiman-plugins.git"
git fetch
git checkout master
git branch --set-upstream-to=origin/master
git pull
- name: Apiman Default API Catalog Code Checkout
run: |
git clone "https://apiman-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apiman/apiman-api-catalog.git"
cd apiman-api-catalog
git fetch
git checkout master
git branch --set-upstream-to=origin/master
git pull
- name: Apiman Default Plugin Registry Code Checkout
run: |
git clone "https://apiman-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apiman/apiman-plugin-registry.git"
cd apiman-plugin-registry
git fetch
git checkout master
git branch --set-upstream-to=origin/master
git pull
# Update all project versions to the version # being released
- name: Update Apiman *Parent* Release Version ${{ github.event.inputs.release-version }} in pom.xml
- name: Update Apiman *Parent* Release Version ${{ env.RELEASE_VERSION }} in pom.xml
run: |
cd apiman/parent
mvn -ntp clean install
mvn -ntp versions:set -DnewVersion="${{ github.event.inputs.release-version }}" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp versions:set -DnewVersion="$RELEASE_VERSION" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp clean install
- name: Update Apiman Release Version ${{ github.event.inputs.release-version }} in pom.xml
- name: Update Apiman Release Version ${{ env.RELEASE_VERSION }} in pom.xml
run: |
cd apiman
mvn -ntp -N versions:update-parent -DparentVersion="[${{ github.event.inputs.release-version }}]" -DgenerateBackupPoms=false
mvn -ntp versions:set -DnewVersion="${{ github.event.inputs.release-version }}" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp -N versions:update-parent -DparentVersion="[$RELEASE_VERSION]" -DgenerateBackupPoms=false
mvn -ntp versions:set -DnewVersion="$RELEASE_VERSION" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp clean install
- name: Update Apiman Version in Plugins Project
run: |
cd plugins
sed -i "s/<version.apiman>.*<\/version.apiman>/<version.apiman>${{ github.event.inputs.release-version }}<\/version.apiman>/g" pom.xml
sed -i "s/<version.apiman>.*<\/version.apiman>/<version.apiman>$RELEASE_VERSION<\/version.apiman>/g" pom.xml
- name: Update Apiman Plugins Release Version ${{ github.event.inputs.release-version }} in pom.xml
- name: Update Apiman Plugins Release Version ${{ env.RELEASE_VERSION }} in pom.xml
run: |
cd plugins
mvn -ntp -N versions:update-parent -DparentVersion="[${{ github.event.inputs.release-version }}]" -DgenerateBackupPoms=false
mvn -ntp versions:set -DnewVersion="${{ github.event.inputs.release-version }}" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp -N versions:update-parent -DparentVersion="[$RELEASE_VERSION]" -DgenerateBackupPoms=false
mvn -ntp versions:set -DnewVersion="$RELEASE_VERSION" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp clean install
- name: Commit changes for Apiman Plugin Registry
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
DEV_VERSION: ${{ github.event.inputs.snapshot-version }}
run: |
cd apiman-plugin-registry
bash release.sh
- name: Commit changes for Apiman API Catalog
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
DEV_VERSION: ${{ github.event.inputs.snapshot-version }}
run: |
cd apiman-api-catalog
bash release.sh
- name: Update Registry and Catalog links in Apiman
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
DEV_VERSION: ${{ github.event.inputs.snapshot-version }}
run: |
find . -name "*.properties" -exec sed -i "s|apiman-manager.api-catalog.catalog-url=https://cdn.jsdelivr.net/gh/apiman/apiman-api-catalog@master/catalog.json|apiman-manager.api-catalog.catalog-url=https://cdn.jsdelivr.net/gh/apiman/apiman-api-catalog@$RELEASE_VERSION/catalog.json|" {} \;
find . -name "*.properties" -exec sed -i "s|apiman-manager.plugins.registries=https://cdn.jsdelivr.net/gh/apiman/apiman-plugin-registry@master/registry.json|apiman-manager.plugins.registries=https://cdn.jsdelivr.net/gh/apiman/apiman-plugin-registry@$RELEASE_VERSION/registry.json|" {} \;
# Commit changes back to GitHub
- name: Commit Changes for Apiman Release Version ${{ github.event.inputs.release-version }}
- name: Commit Changes for Apiman Release Version ${{ env.RELEASE_VERSION }}
run: |
cd apiman
git add .
git commit -m "Automated commit for Release Version: ${{ github.event.inputs.release-version }}"
git tag -f -a -m "Tagging release ${{ github.event.inputs.release-version }}" ${{ github.event.inputs.release-version }}
git push --atomic origin ${{ github.event.inputs.release-version }}:${{ github.event.inputs.release-version }}
git commit -m "Automated commit for Release Version: $RELEASE_VERSION"
git tag -f -a -m "Tagging release $RELEASE_VERSION" $RELEASE_VERSION
cd portal/ui
git add .
git commit -m "Automated commit for Release Version: $RELEASE_VERSION"
git tag -f -a -m "Tagging release $RELEASE_VERSION" $RELEASE_VERSION
cd ../..
git push --recurse-submodules=on-demand --atomic origin $RELEASE_VERSION:$RELEASE_VERSION
- name: Commit Changes for Apiman Plugins Release Version ${{ github.event.inputs.release-version }}
- name: Commit Changes for Apiman Plugins Release Version ${{ env.RELEASE_VERSION }}
run: |
cd plugins
git add .
git commit -m "Automated commit for Release Version: ${{ github.event.inputs.release-version }}"
git tag -f -a -m "Tagging release ${{ github.event.inputs.release-version }}" ${{ github.event.inputs.release-version }}
git push --atomic origin ${{ github.event.inputs.release-version }}:${{ github.event.inputs.release-version }}
git commit -m "Automated commit for Release Version: $RELEASE_VERSION"
git tag -f -a -m "Tagging release $RELEASE_VERSION" $RELEASE_VERSION
git push --atomic origin $RELEASE_VERSION:$RELEASE_VERSION
# Create GitHub "release" with attached assets
- name: Signing and Archiving the Quickstart ZIPs
run: |
cd apiman
mkdir -p releases
cp distro/wildfly/target/apiman-distro-wildfly-${{ github.event.inputs.release-version }}-overlay.zip releases/.
cp distro/vertx/target/apiman-distro-vertx-${{ github.event.inputs.release-version }}.zip releases/.
cp distro/tomcat/target/apiman-distro-tomcat-${{ github.event.inputs.release-version }}-overlay.zip releases/.
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --passphrase-fd 0 --armor --detach-sign releases/apiman-distro-wildfly-${{ github.event.inputs.release-version }}-overlay.zip
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --passphrase-fd 0 --armor --detach-sign releases/apiman-distro-vertx-${{ github.event.inputs.release-version }}.zip
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --passphrase-fd 0 --armor --detach-sign releases/apiman-distro-tomcat-${{ github.event.inputs.release-version }}-overlay.zip
cp distro/wildfly/target/apiman-distro-wildfly-$RELEASE_VERSION-overlay.zip releases/.
cp distro/vertx/target/apiman-distro-vertx-$RELEASE_VERSION.zip releases/.
cp distro/tomcat/target/apiman-distro-tomcat-$RELEASE_VERSION-overlay.zip releases/.
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --passphrase-fd 0 --armor --detach-sign releases/apiman-distro-wildfly-$RELEASE_VERSION-overlay.zip
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --passphrase-fd 0 --armor --detach-sign releases/apiman-distro-vertx-$RELEASE_VERSION.zip
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --passphrase-fd 0 --armor --detach-sign releases/apiman-distro-tomcat-$RELEASE_VERSION-overlay.zip
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}/apiman/CHANGELOG.adoc
tag_name: ${{ github.event.inputs.release-version }}
name: ${{ github.event.inputs.release-version }}
prerelease: false
files: |
/home/runner/work/apiman/apiman/apiman/releases/apiman-distro-wildfly-${{ github.event.inputs.release-version }}-overlay.zip
/home/runner/work/apiman/apiman/apiman/releases/apiman-distro-wildfly-${{ github.event.inputs.release-version }}-overlay.zip.asc
/home/runner/work/apiman/apiman/apiman/releases/apiman-distro-vertx-${{ github.event.inputs.release-version }}.zip
/home/runner/work/apiman/apiman/apiman/releases/apiman-distro-vertx-${{ github.event.inputs.release-version }}.zip.asc
/home/runner/work/apiman/apiman/apiman/releases/apiman-distro-tomcat-${{ github.event.inputs.release-version }}-overlay.zip
/home/runner/work/apiman/apiman/apiman/releases/apiman-distro-tomcat-${{ github.event.inputs.release-version }}-overlay.zip.asc
${{ github.workspace }}/apiman/releases/apiman-distro-wildfly-$RELEASE_VERSION-overlay.zip
${{ github.workspace }}/apiman/releases/apiman-distro-wildfly-$RELEASE_VERSION-overlay.zip.asc
${{ github.workspace }}/apiman/releases/apiman-distro-vertx-$RELEASE_VERSION.zip
${{ github.workspace }}/apiman/releases/apiman-distro-vertx-$RELEASE_VERSION.zip.asc
${{ github.workspace }}/apiman/releases/apiman-distro-tomcat-$RELEASE_VERSION-overlay.zip
${{ github.workspace }}/apiman/releases/apiman-distro-tomcat-$RELEASE_VERSION-overlay.zip.asc
# releases/apiman-distro-tomcat-${{ github.event.inputs.release-version }}-overlay.zip
- name: Generate Release Notes
run: cd apiman && gren release --token=${{ secrets.GITHUB_TOKEN }} --override
# - name: Generate Release Notes
# run: cd apiman && gren release --token=${{ secrets.GITHUB_TOKEN }} --override

# Deploy Apiman to Maven Central
- name: Deploy Apiman to Maven Central
run: |
cd apiman
mvn deploy --batch-mode -DskipTests -Prelease --settings /home/runner/.m2/settings.xml
mvn deploy --batch-mode -DskipTests -Prelease
cd parent
mvn deploy --batch-mode -DskipTests -Prelease --settings /home/runner/.m2/settings.xml
mvn deploy --batch-mode -DskipTests -Prelease
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

# Deploy Apiman Plugins to Maven Central
- name: Deploy Apiman Plugins to Maven Central
Expand All @@ -217,37 +203,41 @@ jobs:
mvn deploy --batch-mode -DskipTests -Prelease --settings /home/runner/.m2/settings.xml
# Update project pom.xml files to next snapshot version and push to GH
- name: Update Apiman Parent Next Snapshot Version ${{ github.event.inputs.snapshot-version }} in pom.xml
- name: Update Apiman Parent Next Snapshot Version ${{ env.DEV_VERSION }} in pom.xml
run: |
cd apiman/parent
mvn -ntp versions:set -DnewVersion="${{ github.event.inputs.snapshot-version }}" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp versions:set -DnewVersion="$DEV_VERSION" -DgenerateBackupPoms=false -DprocessAllModules=true
- name: Update Apiman Next Snapshot Version ${{ github.event.inputs.snapshot-version }} in pom.xml
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
- name: Update Apiman Next Snapshot Version ${{ env.DEV_VERSION }} in pom.xml
run: |
cd apiman
mvn -ntp versions:set -DnewVersion="${{ github.event.inputs.snapshot-version }}" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp versions:update-parent -DparentVersion="[${{ github.event.inputs.snapshot-version }}]" -DgenerateBackupPoms=false -DallowSnapshots=true
mvn -ntp versions:set -DnewVersion="$DEV_VERSION" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp versions:update-parent -DparentVersion="[$DEV_VERSION]" -DgenerateBackupPoms=false -DallowSnapshots=true
find . -name "*.properties" -exec sed -i "s|apiman-manager.api-catalog.catalog-url=https://cdn.jsdelivr.net/gh/apiman/apiman-api-catalog@$RELEASE_VERSION/catalog.json|apiman-manager.api-catalog.catalog-url=https://cdn.jsdelivr.net/gh/apiman/apiman-api-catalog@master/catalog.json|" {} \;
find . -name "*.properties" -exec sed -i "s|apiman-manager.plugins.registries=https://cdn.jsdelivr.net/gh/apiman/apiman-plugin-registry@$RELEASE_VERSION/registry.json|apiman-manager.plugins.registries=https://cdn.jsdelivr.net/gh/apiman/apiman-plugin-registry@master/registry.json|" {} \;
- name: Update Apiman Plugins Next Snapshot Version ${{ github.event.inputs.snapshot-version }} in pom.xml
- name: Update Apiman Plugins Next Snapshot Version ${{ env.DEV_VERSION }} in pom.xml
run: |
cd plugins
mvn -ntp versions:set -DnewVersion="${{ github.event.inputs.snapshot-version }}" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp versions:update-parent -DparentVersion="[${{ github.event.inputs.snapshot-version }}]" -DgenerateBackupPoms=false -DallowSnapshots=true
mvn -ntp versions:set -DnewVersion="$DEV_VERSION" -DgenerateBackupPoms=false -DprocessAllModules=true
mvn -ntp versions:update-parent -DparentVersion="[$DEV_VERSION]" -DgenerateBackupPoms=false -DallowSnapshots=true
- name: Commit Changes for Apiman Next Snapshot Version ${{ github.event.inputs.snapshot-version }}
- name: Commit Changes for Apiman Next Snapshot Version ${{ env.DEV_VERSION }}
run: |
cd apiman
git commit -am "Automated commit for Next Snapshot Version: ${{ github.event.inputs.snapshot-version }}"
git push
git commit -am "Automated commit for Next Snapshot Version: $DEV_VERSION"
cd portal/ui
git commit -am "Automated commit for Next Snapshot Version: $DEV_VERSION"
cd ../..
git push --recurse-submodules=on-demand --atomic origin
- name: Commit Changes for Apiman Plugins Next Snapshot Version ${{ github.event.inputs.snapshot-version }}
- name: Commit Changes for Apiman Plugins Next Snapshot Version ${{ env.DEV_VERSION }}
run: |
cd plugins
git commit -am "Automated commit for Next Snapshot Version: ${{ github.event.inputs.snapshot-version }}"
git commit -am "Automated commit for Next Snapshot Version: $DEV_VERSION"
git push
- name: 'Send `apiman-release-version` repository dispatch event to `apiman/apiman-docker`'
Expand Down
2 changes: 1 addition & 1 deletion portal/ui
Submodule ui updated 1 files
+1 −1 pom.xml

0 comments on commit f87f7c0

Please sign in to comment.