Skip to content

Commit d301b2d

Browse files
Add GitHub action to create release candidates
Although the release candidate container has helped to make builds reproducible and limit the amount of setup needed, it is still difficult to setup in some environments. This adds a custom GitHub action and workflow to build/publish release candidates. To implement this, the new custom GitHub action is called "release-candidate" and prepares the GitHub CI environment for creating a release candidate for ASF. This includes things like SBT settings for publishing to ASF maven repositories, creating directories for artifacts on dist.apache.org, importing signing keys, and creating the source artifact. Workflows using this action only need to publish artifacts (e.g. using sbt publishSigned) and write helper binaries to a provided artifacts directory. The post script of the action will then sign, checksum, and commit the artifacts. DAFFODIL-2971
1 parent 42b8539 commit d301b2d

File tree

10 files changed

+160235
-0
lines changed

10 files changed

+160235
-0
lines changed

.github/workflows/check-dist.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Check GitHub Action Dist
17+
18+
on:
19+
push:
20+
branches-ignore: [ 'dependabot/**' ]
21+
pull_request:
22+
types: [opened, synchronize, reopened]
23+
24+
# Cancel CI runs in progress when a pull request is updated.
25+
concurrency:
26+
group: ${{ github.head_ref || ((github.ref_name != 'main' && github.ref_name) || github.run_id) }}-${{ github.workflow }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
31+
check-dist:
32+
runs-on: ubuntu-22.04
33+
34+
steps:
35+
36+
- name: Checkout
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
39+
- name: Install Node.js
40+
uses: actions/[email protected]
41+
with:
42+
node-version: 20
43+
44+
- name: Build Release Candidate Action
45+
working-directory: actions/release-candidate
46+
run: |
47+
npm install
48+
npm run build
49+
50+
- name: Diff Check
51+
run: git diff --color --exit-code

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Release Candidate Action
2+
3+
This is a GitHub Action that can be used to create release candidates. Note
4+
that it is somewhat opinionated on how release candidates are organized. This
5+
is not intended to be used by all projects.
6+
7+
## Prerequisites
8+
9+
* Apache Security Team has approved the project for
10+
[Automated Release Signing](https://infra.apache.org/release-signing.html#automated-release-signing)
11+
and INFRA has set secrets for the repository, including a GPG signing key,
12+
SVN username/password, and nexus username/password.
13+
* The `runs-on` workflow setting should be Linux based (e.g. `ubuntu-latest`)
14+
* The repository must be checked out using `actions/checkout` prior to
15+
triggering this action
16+
* The repository must have a `VERSION` file containing the current version of the
17+
project (e.g. `1.0.0`)
18+
* When triggered from a tag, the tag must follow the pattern `v<VERSION>-*`
19+
(e.g. `v1.0.0-rc1`)
20+
* When triggered from a tag, the tag must be signed and verified by a key
21+
listed in `https://downloads.apache.org/<tlp_dir>/KEYS`.
22+
23+
## Setup Operations
24+
25+
Below are the operations this action does to setup the environment for a
26+
release candidate workflow:
27+
28+
* Checkout the project's `dist/dev/` SVN directory and create a directory for
29+
release artifacts in `https://dist.apache.org/repos/dist/dev/<tlp_dir>/<project_dir>/<version>-rcX`.
30+
The `artifact_dir` output is set to this directory. Note that `<project_dir>`
31+
is optional if the artifact directory should be in the root of the
32+
`<tlp_dir>`
33+
* Delete previous release candidates from `dist/dev/` for the same version
34+
Useful if an rc fails the VOTE and another is created
35+
* Create a zip source artifact using git archive. The artifact is written to
36+
`src/apache-<project_id>-<version>-src.zip` in the above artifact directory
37+
* Export `SOURCE_DATE_EPOCH` environment variable to match the timestamp of the
38+
current commit
39+
* Configure global SBT [Simple Build Tool](https://scala-sbt.org) settings to
40+
enabling publishing signed jars to the ASF nexus staging repository. Workflow
41+
steps can use `sbt pubilshSigned` without needing any other configuration. If
42+
publishing is disabled, SBT is configured to publish to a local maven repo on
43+
the CI system, so `sbt publishSigned` can still be used without actually
44+
publishing anything.
45+
46+
## Post Operations
47+
48+
If the workflow job does not succeed, none of the following actions are taken.
49+
Files added to `dist/dev/` will not be committed. If the workflow published
50+
files to the ASF staging nexus repository, those files must be manually
51+
dropped.
52+
53+
If the workflow job successfully completes, the following actions are performed
54+
at the end of the workflow:
55+
56+
* Create sha512 checksum files for all artifacts
57+
* Create detached ASCII armored GPG signatures for all artifacts
58+
* Sign all rpm artifacts with the GPG key with rpmsign
59+
* Commit all files added to `dist/dev/` to SVN
60+
61+
Note that committing to SVN is is disabled if any of the following are true:
62+
* The `publish` input is not explicitly set to `true`
63+
* The `VERSION` file contains `-SNAPSHOT`
64+
* The workflow is not triggered from the push of a tag
65+
* The repository is not in the `apache` organization
66+
67+
If any of the above are true and publishing is disabled, the artifact directory
68+
is uploaded as a GitHub workflow artifact. It will be retained for one day.
69+
This is useful for testing the workflow using workflow dispatch.
70+
71+
## Inputs
72+
73+
| Input | Required | Default | Description |
74+
|-----------------|----------|---------|-------------|
75+
| tlp_dir | yes | | Directory of the top level project in dist/dev/ |
76+
| project_name | yes | | Human readable name of the project |
77+
| project_id | yes | | ID of the project, used in source artifact file name |
78+
| project_dir | no | "" | Directory for the project in dev/dist/<tlp_dir>/. Omit if at the root |
79+
| gpg_signing_key | yes | | Key used to sign artifacts |
80+
| svn_username | yes | | Username for publishing release artifacts to SVN dev/dist |
81+
| svn_password | yes | | Password for publishing release artifacts to SVN dev/dist |
82+
| nexus_username | yes | | Username for publishing release artifacts to Nexus |
83+
| nexus_password | yes | | Password for publishing release artifacts to Nexus |
84+
| publish | no | false | Enable/disabling publish artifacts. Must be explicitly set to true to enable publishing. May be ignored depending on other factors. |
85+
86+
## Outputs
87+
88+
| Output | Description |
89+
|-----------------|-------------|
90+
| artifact_dir | Directory where additional release artifacts can be added by the workflow. They are automatically signed, checksumed, and published at the end of the workflow |
91+
92+
## Example Workflow
93+
94+
```yaml
95+
name: Release Candidate
96+
97+
# triggered via release candidate tags or manually via workflow dispatch, note
98+
# that publishing is disabled if not triggered from a tag
99+
on:
100+
push:
101+
tags:
102+
- 'v*-rc*'
103+
workflow_dispatch:
104+
105+
jobs:
106+
107+
release-candidate:
108+
name: RC ${{ github.ref_name }}
109+
runs-on: ubuntu-latest
110+
111+
steps:
112+
113+
- name: Checkout Repository
114+
uses: actions/checkout@v4
115+
116+
- name: ASF Release Candidate
117+
id: rc
118+
uses: apache/daffodil-infrastructure/release-candidate@main
119+
with:
120+
tlp_dir: 'daffodil'
121+
project_name: 'Apache Daffodil'
122+
project_id: 'daffodil'
123+
gpg_signing_key: ${{ secrets.GPG_PRIVATE_KEY }}
124+
svn_username: ${{ secrets.SVN_USERNAME }}
125+
svn_password: ${{ secrets.SVN_PASSWORD }}
126+
nexus_username: ${{ secrets.NEXUS_USERNAME }}
127+
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
128+
publish: true
129+
130+
- name: Install Dependencies
131+
run: |
132+
sudo apt-get -y install ...
133+
...
134+
135+
- name: Create Binary Artifacts
136+
run: |
137+
sbt compile publishSigned ...
138+
139+
ARTIFACT_DIR=${{ steps.rc.outputs.artifact_dir }}
140+
ARTIFACT_BIN_DIR=$ARTIFACT_DIR/bin
141+
142+
# copy helper binaries to the artifact bin directory, these will be
143+
# automatically signed, checksumed, and comitted to dist/dev/
144+
mkdir -p $ARTIFACT_BIN_DIR
145+
cp ... $ARTIFACT_BIN_DIR/
146+
```
147+
148+
# Development
149+
150+
GitHub actions require that any changes made to the files in the `src/`
151+
directory are compiled into index.js files in `dist/` subdirectories. To do
152+
this, run the commands:
153+
154+
```bash
155+
npm install
156+
npm run build
157+
```
158+
159+
The changes this makes to `dist/` must be committed along with the changes to
160+
`src/`.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: 'ASF Release Candidate'
17+
description: >
18+
Action to setup environment and publish ASF release candidates
19+
20+
inputs:
21+
tlp_dir:
22+
description: Directory of the top level project in dist/dev/
23+
required: true
24+
project_name:
25+
description: Human readable name of the project
26+
required: true
27+
project_id:
28+
description: ID of the project, used in source artifact file name
29+
required: true
30+
project_dir:
31+
description: Directory for the project in dev/dist/<tlp_dir>/. Omit if at the root
32+
required: false
33+
default: ""
34+
gpg_signing_key:
35+
description: Key used to sign artifacts
36+
required: true
37+
svn_username:
38+
description: Username for publishing release artifacts to SVN dev/dist
39+
required: true
40+
svn_password:
41+
description: Password for publishing release artifacts to SVN dev/dist
42+
required: true
43+
nexus_username:
44+
description: Username for publishing release artifacts to Nexus
45+
required: true
46+
nexus_password:
47+
description: Password for publishing release artifacts to Nexus
48+
required: true
49+
publish:
50+
description: Enable/disabling publish artifacts. Must be explcitly set to true to enable publishing. Maybe ignored depending on other factors.
51+
required: false
52+
default: false
53+
54+
outputs:
55+
artifact_dir:
56+
description: Directory where additional release artifacts can be added by the workflow. They are automatically signed, checksumed, and published at the end of the workflow
57+
58+
runs:
59+
using: node20
60+
main: dist/main/index.js
61+
post: dist/post/index.js
62+
post-if: success()

0 commit comments

Comments
 (0)