|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: Draft Release |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + tags: |
| 23 | + - 'draft/**' |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + id-token: write |
| 28 | + |
| 29 | +jobs: |
| 30 | + upload-to-atr: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v6 |
| 35 | + - uses: actions/setup-node@v6 |
| 36 | + with: |
| 37 | + node-version: 24 |
| 38 | + |
| 39 | + - name: Setup environment variables |
| 40 | + run: | |
| 41 | + REPO_NAME="${GITHUB_REPOSITORY#*/}" |
| 42 | + TAG_NAME="${GITHUB_REF#refs/tags/}" |
| 43 | + TARGET_RELEASE_VERSION="${TAG_NAME#draft/}" |
| 44 | + SRC_PACKAGE_NAME=${REPO_NAME}-source-${TARGET_RELEASE_VERSION} |
| 45 | + SRC_PACKAGE_TAR=${SRC_PACKAGE_NAME}.tar |
| 46 | + SRC_PACKAGE_TAR_GZ=${SRC_PACKAGE_NAME}.tar.gz |
| 47 | + SRC_PACKAGE_ZIP=${SRC_PACKAGE_NAME}.zip |
| 48 | + NPM_PACKAGE_NAME=${REPO_NAME}-npm-${TARGET_RELEASE_VERSION} |
| 49 | +
|
| 50 | + echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV |
| 51 | + echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV |
| 52 | + echo "TARGET_RELEASE_VERSION=$TARGET_RELEASE_VERSION" >> $GITHUB_ENV |
| 53 | + echo "SRC_PACKAGE_NAME=$SRC_PACKAGE_NAME" >> $GITHUB_ENV |
| 54 | + echo "SRC_PACKAGE_TAR=$SRC_PACKAGE_TAR" >> $GITHUB_ENV |
| 55 | + echo "SRC_PACKAGE_TAR_GZ=$SRC_PACKAGE_TAR_GZ" >> $GITHUB_ENV |
| 56 | + echo "SRC_PACKAGE_ZIP=$SRC_PACKAGE_ZIP" >> $GITHUB_ENV |
| 57 | + echo "NPM_PACKAGE_NAME=$NPM_PACKAGE_NAME" >> $GITHUB_ENV |
| 58 | +
|
| 59 | + echo "REPO_NAME=$REPO_NAME" |
| 60 | + echo "TAG_NAME=$TAG_NAME" |
| 61 | + echo "TARGET_RELEASE_VERSION=$TARGET_RELEASE_VERSION" |
| 62 | + echo "SRC_PACKAGE_NAME=$SRC_PACKAGE_NAME" |
| 63 | + echo "SRC_PACKAGE_TAR=$SRC_PACKAGE_TAR" |
| 64 | + echo "SRC_PACKAGE_TAR_GZ=$SRC_PACKAGE_TAR_GZ" |
| 65 | + echo "SRC_PACKAGE_ZIP=$SRC_PACKAGE_ZIP" |
| 66 | + echo "NPM_PACKAGE_NAME=$NPM_PACKAGE_NAME" |
| 67 | +
|
| 68 | + - name: Verify Target Release Version |
| 69 | + run: | |
| 70 | + PACKAGE_VERSION=$(jq -r '.version' package.json) |
| 71 | + if [ $PACKAGE_VERSION != "$TARGET_RELEASE_VERSION" ]; then |
| 72 | + echo "Mismatch version detected between tag version ($TARGET_RELEASE_VERSION) and package version ($PACKAGE_VERSION)" |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | +
|
| 76 | + if [ -f "plugin.xml" ]; then |
| 77 | + PLUGIN_VERSION=$(yq -p=xml -o=json '.plugin.+@version' plugin.xml) |
| 78 | + if [ $PLUGIN_VERSION != "$TARGET_RELEASE_VERSION" ]; then |
| 79 | + echo "Mismatch version detected between tag version ($TARGET_RELEASE_VERSION) and plugin version ($PLUGIN_VERSION)" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | + fi |
| 83 | +
|
| 84 | + - name: Generate "tgz" npm convenience package |
| 85 | + run: |- |
| 86 | + npm install |
| 87 | + NPM_PKG_NAME=$(npm pack --json | jq -r '.[0].filename') |
| 88 | + mv ./.asf-release/$NPM_PKG_NAME ./.asf-release/${NPM_PACKAGE_NAME}.tgz |
| 89 | + env: |
| 90 | + TZ: UTC |
| 91 | + |
| 92 | + - name: Generate "tar" source package |
| 93 | + run: |- |
| 94 | + export SRC_LAST_COMMIT_EPOCH=$(git log -1 --format=%ct "$TAG_NAME") |
| 95 | +
|
| 96 | + git archive \ |
| 97 | + --prefix=$SRC_PACKAGE_NAME/ \ |
| 98 | + --mtime=$SRC_LAST_COMMIT_EPOCH \ |
| 99 | + -o ./.asf-release/${SRC_PACKAGE_TAR} \ |
| 100 | + $TAG_NAME |
| 101 | + env: |
| 102 | + TZ: UTC |
| 103 | + |
| 104 | + - name: Generate "tar.gz" source archive |
| 105 | + working-directory: ./.asf-release |
| 106 | + run: |- |
| 107 | + gzip -n -9 -c "$SRC_PACKAGE_TAR" > "$SRC_PACKAGE_TAR_GZ" |
| 108 | + env: |
| 109 | + TZ: UTC |
| 110 | + |
| 111 | + - name: Generate "zip" source archive |
| 112 | + working-directory: ./.asf-release |
| 113 | + run: |- |
| 114 | + export ASF_RELEASE_DIR=$(pwd) |
| 115 | + export TMP_DIR=$(mktemp -d) |
| 116 | +
|
| 117 | + tar -xf "$SRC_PACKAGE_TAR" -C "$TMP_DIR" |
| 118 | + ( |
| 119 | + cd "$TMP_DIR" |
| 120 | + find . -type f | LC_ALL=C sort | zip -X -q "$ASF_RELEASE_DIR/$SRC_PACKAGE_ZIP" -@ |
| 121 | + ) |
| 122 | + rm -rf $TMP_DIR |
| 123 | + env: |
| 124 | + TZ: UTC |
| 125 | + |
| 126 | + - name: Cleanup Process |
| 127 | + working-directory: ./.asf-release |
| 128 | + run: |- |
| 129 | + rm -rf $SRC_PACKAGE_TAR |
| 130 | + rm -rf .gitkeep |
| 131 | +
|
| 132 | + - name: Create Sign and Checksum |
| 133 | + working-directory: .asf-release |
| 134 | + run: |- |
| 135 | + for f in *.tar.gz *.tgz *.zip; do |
| 136 | + [ -e "$f" ] || continue |
| 137 | + echo "$CORDOVA_GPG_SECRET_KEY" | gpg --batch --import --import-options import-show |
| 138 | + gpg --armor --detach-sign "$f" |
| 139 | + sha512sum "$f" > "${f}.sha512" |
| 140 | + done |
| 141 | + env: |
| 142 | + CORDOVA_GPG_SECRET_KEY: ${{ secrets.CORDOVA_GPG_SECRET_KEY }} |
| 143 | + |
| 144 | + - name: Upload to Apache Trusted Release (ATR) |
| 145 | + uses: apache/tooling-actions/upload-to-atr@b7e972c11790ee16eca101900af1b3c7fd1b106e |
| 146 | + with: |
| 147 | + project: ${{ env.REPO_NAME }} |
| 148 | + version: ${{ env.TARGET_RELEASE_VERSION }} |
| 149 | + src: .asf-release |
0 commit comments