Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(release): add release scripts and workflow #150

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
go: [ '1.21', '1.22' ]
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: RC
on:
push:
branches:
- '**'
- '!dependabot/**'
tags:
- '*-rc*'
pull_request:

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read

jobs:
archive:
name: Archive
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare for tag
if: github.ref_type == 'tag'
run: |
version=${GITHUB_REF_NAME%-rc}
version=${version#v}
rc=${GITHUB_REF_NAME#*-rc}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make the RC number configurable in the GH action

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RC number is configurable: it is taken from the tag which kicks off the GH action run.

i.e. we kick off the action by creating a tag v0.1.0-rc1 and starting the action:

version=${GITHUB_REF_NAME%-rc}
version=${version#v}

After this, version == 0.1.0-rc1

rc=${GITHUB_REF_NAME#*-rc}

After this, rc == 1.

Thus the RC is configured by the tag that triggers the GH action.

echo "VERSION=${version}" >> ${GITHUB_ENV}
echo "RC=${rc}" >> ${GITHUB_ENV}
- name: Prepare for branch
if: github.ref_type == 'branch'
run: |
rc=100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be configurable from the GH action?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the runs that aren't creating an RC, but are for validating and testing the RC script itself (and ensuring any changes to the RC script don't break it). so the choice of rc=100 here is just picking a number that is unlikely to ever happen naturally to avoid any conflicts. This will not get used to construct an actual RC

echo "VERSION=${version}" >> ${GITHUB_ENV}
echo "RC=${rc}" >> ${GITHUB_ENV}
- name: Archive
run: |
id="apache-iceberg-go-${VERSION}"
tar_gz="${id}.tar.gz"
echo "TAR_GZ=${tar_gz}" >> ${GITHUB_ENV}
git archive HEAD --prefix "${id}/" --output "${tar_gz}"
sha256sum "${tar_gz}" > "${tar_gz}.sha256"
sha512sum "${tar_gz}" > "${tar_gz}.sha512"
- name: Audit
run: |
dev/release/run_rat.sh "${TAR_GZ}"
- uses: actions/upload-artifact@v4
with:
name: archive
path: |
apache-iceberg-go-*

verify:
name: Verify
needs:
- archive
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: archive
- name: Verify
run: |
tar_gz=$(echo apache-iceberg-go-*.tar.gz)
version=${tar_gz#apache-iceberg-go-}
version=${version%.tar.gz}
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
rc="${GITHUB_REF_NAME#*-rc}"
else
rc=100
fi
VERIFY_DEFAULT=0 dev/release/verify_rc.sh "${version}" "${rc}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload:
name: upload
if: github.ref_type == 'tag'
needs:
- verify
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: archive
- name: Upload
run: |
# TODO: Add support for release notes
gh release create ${GITHUB_REF_NAME} \
--prerelease \
--title "Apache Iceberg Go ${GITHUB_REF_NAME}" \
--verify-tag \
apache-iceberg-go-*.tar.gz \
apache-iceberg-go-*.tar.gz.sha*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ lib/

# local catalog environment via docker
dev/notebooks
dev/warehouse
dev/warehouse

/apache-iceberg-go-*.tar.gz
/apache-iceberg-go-*.tar.gz.asc
/dev/release/apache-rat-*.jar
/dev/release/filtered_rat.txt
/dev/release/rat.xml
8 changes: 0 additions & 8 deletions dev/.rat-excludes

This file was deleted.

2 changes: 1 addition & 1 deletion dev/check-license
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mkdir -p "$FWDIR"/lib
}

mkdir -p build
$java_cmd -jar "$rat_jar" -E "$FWDIR"/dev/.rat-excludes -d "$FWDIR" > build/rat-results.txt
$java_cmd -jar "$rat_jar" -E "$FWDIR"/dev/release/rat_exclude_files.txt -d "$FWDIR" > build/rat-results.txt

if [ $? -ne 0 ]; then
echo "RAT exited abnormally"
Expand Down
105 changes: 105 additions & 0 deletions dev/release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!---
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# Release

## Overview

1. Test the revision to be released
2. Prepare RC and vote (detailed later)
3. Publish (detailed later)

### Prepare RC and vote

Run `dev/release/release_rc.sh` on a working copy of
`[email protected]:apache/iceberg-go` not from your fork:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the working copy of .. not from your fork actually mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to run the release_rc.sh script on a direct clone of github.com/apache/iceberg-go where the remote origin refers to the primary repository, not a users fork where they do normal development.


```console
$ git clone [email protected]:apache/iceberg-go.git
$ dev/release/release_rc.sh ${VERSION} ${RC}
(Send a vote email to [email protected].
You can use a draft shown by release_rc.sh for the email.)
```

Here is an example to release RC1:

```console
$ GH_TOKEN=${YOUR_GITHUB_TOKEN} dev/release/release_rc.sh 1.0.0 1
```

The arguments of `release_rc.sh` are the version and the RC number. If RC1 has a problem, we'll increment the RC number such as RC2, RC3 and so on.

Requirements to run `release_rc.sh`:

* You must be an Apache Iceberg committer or PMC member
* You must prepare your PGP key for signing

If you don't have a PGP key, https://infra.apache.org/release-signing.html#generate
may be helpful.

Your PGP key must be registered to the following:

* https://dist.apache.org/repos/dist/dev/iceberg/KEYS
* https://dist.apache.org/repos/dist/release/iceberg/KEYS

See the header comment of them for how to add a PGP key.

Apache Iceberg committers can update them by Subversion client with their ASF account.
e.g.:

```console
$ svn co https://dist.apache.org/repos/dist/dev/iceberg
$ cd iceberg
$ editor KEYS
$ svn ci KEYS
```

### Publish

We need to do the following to publish a new release:

* Publish to apache.org

Run `dev/release/release.sh` to publish to apache.org:

```console
$ GH_TOKEN=${YOUR_GITHUB_TOKEN} dev/release/release.sh ${VERSION} ${RC}
```

Add the release to ASF's report database via [Apache Committee Report Helper](https://reporter.apache.org/addrelease.html?iceberg)

### Verify

We have a script for verifying a RC.

You must install the following to run the script:

* `curl`
* `gpg`
* `shasum` or `sha256sum`/`sha512sum`
* `tar`

You don't need to have Go installed, if it isn't on the system the latest Go will be
automatically downloaded and used only for verification.

To verify a RC, run the following:

```console
$ dev/release/verify_rc.sh ${VERSION} ${RC}
```

If the verification is successful, the message `RC looks good!` is shown.
59 changes: 59 additions & 0 deletions dev/release/check_rat_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import fnmatch
import re
import sys
import xml.etree.ElementTree as ET

if len(sys.argv) != 3:
sys.stderr.write("Usage: %s exclude_globs.lst rat_report.xml\n" %
sys.argv[0])
sys.exit(1)

exclude_globs_filename = sys.argv[1]
xml_filename = sys.argv[2]

globs = [line.strip() for line in open(exclude_globs_filename, "r")]

tree = ET.parse(xml_filename)
root = tree.getroot()
resources = root.findall('resource')

all_ok = True
for r in resources:
approvals = r.findall('license-approval')
if not approvals or approvals[0].attrib['name'] == 'true':
continue
clean_name = re.sub('^[^/]+/', '', r.attrib['name'])
excluded = False
for g in globs:
if fnmatch.fnmatch(clean_name, g):
excluded = True
break
if not excluded:
sys.stdout.write("NOT APPROVED: %s (%s): %s\n" % (
clean_name, r.attrib['name'], approvals[0].attrib['name']))
all_ok = False

if not all_ok:
sys.exit(1)

print('OK')
sys.exit(0)
24 changes: 24 additions & 0 deletions dev/release/rat_exclude_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

.gitignore
LICENSE
NOTICE
go.sum
build
rat-results.txt
operation_string.go
Loading
Loading