Skip to content

Commit 8624b09

Browse files
committed
chore(workflow): add draft release
1 parent 544bfe0 commit 8624b09

1 file changed

Lines changed: 155 additions & 0 deletions

File tree

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+
with:
36+
persist-credentials: false
37+
fetch-depth: 1
38+
39+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
40+
with:
41+
node-version: 24
42+
package-manager-cache: false
43+
cache: ''
44+
45+
- name: Setup environment variables
46+
run: |
47+
REPO_NAME="${GITHUB_REPOSITORY#*/}"
48+
TAG_NAME="${GITHUB_REF#refs/tags/}"
49+
TARGET_RELEASE_VERSION="${TAG_NAME#draft/}"
50+
SRC_PACKAGE_NAME=${REPO_NAME}-source-${TARGET_RELEASE_VERSION}
51+
SRC_PACKAGE_TAR=${SRC_PACKAGE_NAME}.tar
52+
SRC_PACKAGE_TAR_GZ=${SRC_PACKAGE_NAME}.tar.gz
53+
SRC_PACKAGE_ZIP=${SRC_PACKAGE_NAME}.zip
54+
NPM_PACKAGE_NAME=${REPO_NAME}-npm-${TARGET_RELEASE_VERSION}
55+
56+
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
57+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
58+
echo "TARGET_RELEASE_VERSION=$TARGET_RELEASE_VERSION" >> $GITHUB_ENV
59+
echo "SRC_PACKAGE_NAME=$SRC_PACKAGE_NAME" >> $GITHUB_ENV
60+
echo "SRC_PACKAGE_TAR=$SRC_PACKAGE_TAR" >> $GITHUB_ENV
61+
echo "SRC_PACKAGE_TAR_GZ=$SRC_PACKAGE_TAR_GZ" >> $GITHUB_ENV
62+
echo "SRC_PACKAGE_ZIP=$SRC_PACKAGE_ZIP" >> $GITHUB_ENV
63+
echo "NPM_PACKAGE_NAME=$NPM_PACKAGE_NAME" >> $GITHUB_ENV
64+
65+
echo "REPO_NAME=$REPO_NAME"
66+
echo "TAG_NAME=$TAG_NAME"
67+
echo "TARGET_RELEASE_VERSION=$TARGET_RELEASE_VERSION"
68+
echo "SRC_PACKAGE_NAME=$SRC_PACKAGE_NAME"
69+
echo "SRC_PACKAGE_TAR=$SRC_PACKAGE_TAR"
70+
echo "SRC_PACKAGE_TAR_GZ=$SRC_PACKAGE_TAR_GZ"
71+
echo "SRC_PACKAGE_ZIP=$SRC_PACKAGE_ZIP"
72+
echo "NPM_PACKAGE_NAME=$NPM_PACKAGE_NAME"
73+
74+
- name: Verify Target Release Version
75+
run: |
76+
PACKAGE_VERSION=$(jq -r '.version' package.json)
77+
if [ "$PACKAGE_VERSION" != "$TARGET_RELEASE_VERSION" ]; then
78+
echo "Mismatch version detected between tag version ($TARGET_RELEASE_VERSION) and package version ($PACKAGE_VERSION)"
79+
exit 1
80+
fi
81+
82+
if [ -f "plugin.xml" ]; then
83+
PLUGIN_VERSION=$(yq -p=xml -o=json '.plugin.+@version' plugin.xml | jq -r .)
84+
if [ "$PLUGIN_VERSION" != "$TARGET_RELEASE_VERSION" ]; then
85+
echo "Mismatch version detected between tag version ($TARGET_RELEASE_VERSION) and plugin version ($PLUGIN_VERSION)"
86+
exit 1
87+
fi
88+
fi
89+
90+
- name: Generate "tgz" npm convenience package
91+
run: |-
92+
npm ci
93+
NPM_PKG_NAME=$(npm pack --json | jq -r '.[0].filename')
94+
mv ./.asf-release/$NPM_PKG_NAME ./.asf-release/${NPM_PACKAGE_NAME}.tgz
95+
env:
96+
TZ: UTC
97+
98+
- name: Generate "tar" source package
99+
run: |-
100+
export SRC_LAST_COMMIT_EPOCH=$(git log -1 --format=%ct "$TAG_NAME")
101+
102+
git archive \
103+
--prefix=$SRC_PACKAGE_NAME/ \
104+
--mtime=$SRC_LAST_COMMIT_EPOCH \
105+
-o ./.asf-release/${SRC_PACKAGE_TAR} \
106+
$TAG_NAME
107+
env:
108+
TZ: UTC
109+
110+
- name: Generate "tar.gz" source archive
111+
working-directory: ./.asf-release
112+
run: |-
113+
gzip -n -9 -c "$SRC_PACKAGE_TAR" > "$SRC_PACKAGE_TAR_GZ"
114+
env:
115+
TZ: UTC
116+
117+
- name: Generate "zip" source archive
118+
working-directory: ./.asf-release
119+
run: |-
120+
export ASF_RELEASE_DIR=$(pwd)
121+
export TMP_DIR=$(mktemp -d)
122+
123+
tar -xf "$SRC_PACKAGE_TAR" -C "$TMP_DIR"
124+
(
125+
cd "$TMP_DIR"
126+
find . -type f | LC_ALL=C sort | zip -X -q "$ASF_RELEASE_DIR/$SRC_PACKAGE_ZIP" -@
127+
)
128+
rm -rf $TMP_DIR
129+
env:
130+
TZ: UTC
131+
132+
- name: Cleanup Process
133+
working-directory: ./.asf-release
134+
run: |-
135+
rm -rf $SRC_PACKAGE_TAR
136+
rm -rf .gitkeep
137+
138+
- name: Create Sign and Checksum
139+
working-directory: .asf-release
140+
run: |-
141+
for f in *.tar.gz *.tgz *.zip; do
142+
[ -e "$f" ] || continue
143+
echo "$CORDOVA_GPG_SECRET_KEY" | gpg --batch --import --import-options import-show
144+
gpg --armor --detach-sign "$f"
145+
sha512sum "$f" > "${f}.sha512"
146+
done
147+
env:
148+
CORDOVA_GPG_SECRET_KEY: ${{ secrets.CORDOVA_GPG_SECRET_KEY }}
149+
150+
- name: Upload to Apache Trusted Release (ATR)
151+
uses: apache/tooling-actions/upload-to-atr@f5f4c0e7ddfbde6b1f8288cef36324c6def68051
152+
with:
153+
project: ${{ env.REPO_NAME }}
154+
version: ${{ env.TARGET_RELEASE_VERSION }}
155+
src: .asf-release

0 commit comments

Comments
 (0)