Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
sharunkumar committed Nov 15, 2024
2 parents be1dfd9 + a93a52b commit f6542e7
Show file tree
Hide file tree
Showing 17 changed files with 1,194 additions and 116 deletions.
77 changes: 28 additions & 49 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,28 @@ on:
is_main_build:
type: boolean
required: true
app_build:
type: string
required: true
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

env:
APP_GIT_REF: ${{ inputs.is_main_build && github.sha || github.ref_name }}
BUILD_LABEL: ${{ inputs.is_main_build && github.sha || github.ref_name }}

concurrency:
group: release

jobs:
# get app build env from git commit message
app_build:
runs-on: ubuntu-latest
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
steps:
- if: inputs.is_main_build != true
run: |
# get app build in parentheses from commit message
APP_BUILD=$(echo "$COMMIT_MSG" | sed -n 's/.*(\([0-9]*\)).*/\1/p')
# verify app_build is a number
if echo "$APP_BUILD" | grep -qE '^[0-9]+$'; then
echo "app_build=$APP_BUILD" >> $GITHUB_OUTPUT
fi
outputs:
app_build: ${{ inputs.app_build || steps.app_build.outputs.app_build }}

build_web:
needs: app_build
runs-on: ubuntu-latest
env:
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
steps:
- uses: actions/checkout@v4

- name: Download bumped version artifacts
if: inputs.is_main_build
uses: actions/download-artifact@v4
with:
name: release-data

- uses: actions/setup-node@v4
with:
node-version: 22
Expand All @@ -69,28 +52,25 @@ jobs:

- name: Compress artifacts
run: |
zip -r Voyager-Web-$APP_GIT_REF.zip dist
zip -r Voyager-Web-$BUILD_LABEL.zip dist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Voyager-Web-${{ env.APP_GIT_REF }}.zip
path: Voyager-Web-${{ env.APP_GIT_REF }}.zip
name: Voyager-Web-${{ env.BUILD_LABEL }}.zip
path: Voyager-Web-${{ env.BUILD_LABEL }}.zip

build_ios:
needs: app_build
environment: deploy
runs-on: macos-15
env:
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
steps:
- uses: actions/checkout@v4

- name: Download bumped version artifacts
if: inputs.is_main_build
uses: actions/download-artifact@v4
with:
name: trapeze-artifacts
name: release-data

- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -133,22 +113,19 @@ jobs:
- name: Upload iOS IPA as artifact
uses: actions/upload-artifact@v4
with:
name: Voyager-iOS-${{ env.APP_GIT_REF }}.ipa
path: Voyager-iOS-${{ env.APP_GIT_REF }}.ipa
name: Voyager-iOS-${{ env.BUILD_LABEL }}.ipa
path: Voyager-iOS-${{ env.BUILD_LABEL }}.ipa

build_android:
needs: app_build
runs-on: ubuntu-latest
env:
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
steps:
- uses: actions/checkout@v4

- name: Download bumped version artifacts
if: inputs.is_main_build
uses: actions/download-artifact@v4
with:
name: trapeze-artifacts
name: release-data

- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -179,28 +156,25 @@ jobs:
ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}

- run: mv android/app/build/outputs/apk/release/app-release.apk Voyager-Android-${{ env.APP_GIT_REF }}.apk
- run: mv android/app/build/outputs/apk/release/app-release.apk Voyager-Android-${{ env.BUILD_LABEL }}.apk

- name: Send to Artifacts
uses: actions/upload-artifact@v4
with:
name: Voyager-Android-${{ env.APP_GIT_REF }}.apk
path: Voyager-Android-${{ env.APP_GIT_REF }}.apk
name: Voyager-Android-${{ env.BUILD_LABEL }}.apk
path: Voyager-Android-${{ env.BUILD_LABEL }}.apk

build_android_play:
needs: app_build
environment: deploy
runs-on: ubuntu-latest
env:
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
steps:
- uses: actions/checkout@v4

- name: Download bumped version artifacts
if: inputs.is_main_build
uses: actions/download-artifact@v4
with:
name: trapeze-artifacts
name: release-data

- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -260,25 +234,30 @@ jobs:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: Voyager-Web-${{ env.APP_GIT_REF }}.zip
name: Voyager-Web-${{ env.BUILD_LABEL }}.zip
path: artifacts/web

- name: Download iOS Artifact
uses: actions/download-artifact@v4
with:
name: Voyager-iOS-${{ env.APP_GIT_REF }}.ipa
name: Voyager-iOS-${{ env.BUILD_LABEL }}.ipa
path: artifacts/ios

- name: Download Android Artifact
uses: actions/download-artifact@v4
with:
name: Voyager-Android-${{ env.APP_GIT_REF }}.apk
name: Voyager-Android-${{ env.BUILD_LABEL }}.apk
path: artifacts/android

# https://github.com/softprops/action-gh-release/pull/372#issuecomment-1642643937
- name: Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@a57c1b7c90e56d9c8b26a6ed5d1eed159369e117 # v5.0.0

- name: Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
with:
generate_release_notes: true
body: ${{ steps.build_changelog.outputs.changelog }}
files: |
artifacts/ios/*
artifacts/android/*
Expand Down
44 changes: 31 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
APP_BUILD=$((${{ github.run_number }} + $APP_BUILD_OFFSET))
echo "app_build=$APP_BUILD" >> $GITHUB_OUTPUT
echo Current build number: $APP_BUILD
echo "App build number: \`$APP_BUILD\`" >> $GITHUB_STEP_SUMMARY
outputs:
app_build: ${{ steps.calculate.outputs.app_build }}

Expand All @@ -44,8 +44,9 @@ jobs:
- name: Get current version from package.json
id: app_version
run: |
CURRENT_APP_VERSION=$(node -p "require('./package.json').version")
echo "app_version=$CURRENT_APP_VERSION" >> $GITHUB_OUTPUT
APP_VERSION=$(node -p "require('./package.json').version")
echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
echo "current app version: $APP_VERSION"
- name: Verify provided version not already released
if: inputs.release_behavior == 'publish_release'
Expand Down Expand Up @@ -75,22 +76,41 @@ jobs:
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
APP_VERSION: ${{ needs.app_version.outputs.app_version }}

- name: Add build metadata
run: |
echo """APP_VERSION=${{ needs.app_version.outputs.app_version }}
APP_BUILD=${{ needs.app_build.outputs.app_build }}
APP_GIT_REF=${{ inputs.release_behavior != 'publish_release' && github.sha || needs.app_version.outputs.app_version }}""" > .env
echo "wrote .env:"
cat .env
- name: Determine changed files
id: determine_changes
run: |
git add .
echo "will upload the following files:"
git --no-pager diff HEAD --name-only
echo "all modifications:"
git --no-pager diff HEAD
echo 'files<<EOF' >> $GITHUB_OUTPUT
git --no-pager diff HEAD --name-only >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: Upload bumped version artifacts
uses: actions/upload-artifact@v4
with:
name: trapeze-artifacts
retention-days: 3
path: |
android
ios
name: release-data
path: ${{ steps.determine_changes.outputs.files }}
include-hidden-files: true # needed for .env

dispatch_beta_release:
if: inputs.release_behavior != 'publish_release'
needs: [app_build, bump_src]
needs: [bump_src]
uses: ./.github/workflows/build_release.yml
with:
is_main_build: true
app_build: ${{ needs.app_build.outputs.app_build }}
secrets: inherit
permissions:
contents: write # needed for create_release, even though it won't be called
Expand All @@ -108,7 +128,7 @@ jobs:
- name: Download bumped version artifacts
uses: actions/download-artifact@v4
with:
name: trapeze-artifacts
name: release-data

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
Expand All @@ -125,13 +145,11 @@ jobs:
# Github doesn't trigger subsequent workflows unless push with a PAT
run: |
git remote set-url origin "https://${PAT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b "release/${{ needs.app_version.outputs.app_version }}"
git config --global user.email "voyager.ci.noreply@harding.dev"
git config --global user.name "Voyager CI"
git add .
git commit -S -m "release: ${{ needs.app_version.outputs.app_version }} (${{ needs.app_build.outputs.app_build }})"
TAG_NAME="${{ needs.app_version.outputs.app_version }}"
echo "Creating tag: $TAG_NAME"
git tag -s "$TAG_NAME" -m "release: ${{ needs.app_version.outputs.app_version }} (${{ needs.app_build.outputs.app_build }})"
git push origin "release/${{ needs.app_version.outputs.app_version }}"
git push origin "$TAG_NAME"
11 changes: 11 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/release-it@17/schema/release-it.json",
"git": {
"commitMessage": "release: bump version to ${version}",
"tag": false,
"getLatestTagFromAllRefs": true
},
"npm": {
"publish": false
}
}
43 changes: 38 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ Voyager uses Github Actions for Apple App Store and Android Play Store builds, w

Note: F-droid and Github Releases binaries are built with `BUILD_FOSS_ONLY=true`. This removes all nonfree dependencies, currently just Google Play in-app purchases.

> [!IMPORTANT]
> Release tags are detached from main so that CI can commit build metadata for fdroid.
>
> You can visualize where release tags have diverged from main like this:
>
> ```sh
> git log --graph --oneline --tags
> ```
>
> To see all commits between a release tag and main, you can use the following (replace `MY_RELEASE_TAG`):
>
> ```sh
> git log main..MY_RELEASE_TAG
> ```
>
> To determine the exact commit where a release tag diverged from main, you can use the following (replace `MY_RELEASE_TAG`):
>
> ```sh
> git rev-parse $(git rev-list --exclude-first-parent-only ^main MY_RELEASE_TAG| tail -1)^
> ```
#### Start the release process
1. Make sure the version is incremented. Increment in `package.json` and push (if necessary)
Expand All @@ -113,10 +134,19 @@ Note: F-droid and Github Releases binaries are built with `BUILD_FOSS_ONLY=true`
#### The `release` workflow will:
1. Set the build number to the current Github run number (and detect the version from `package.json`)
2. Commit the version bump
3. Create a release branch (e.g. `release/1.0.0`)
4. Tag the release (e.g. `1.0.0`)
5. As a side-effect of tagging, trigger the `build_release` workflow
2. Upload `release-data` artifact with trapeze changes and `.env` file
Then, it will fork depending on the `release_behavior` (e.g. building on main or publishing a release):
##### Building on main
1. Dispatch the `build_release` workflow with `is_main_build=true`
##### Publishing a release
2. Commit the `release-data`
3. Tag the release (e.g. `1.0.0`)
4. As a side-effect of tagging, trigger the `build_release` workflow
#### The `build_release` workflow will:
Expand All @@ -125,8 +155,11 @@ Note: F-droid and Github Releases binaries are built with `BUILD_FOSS_ONLY=true`
3. Build iOS artifact — `Voyager-iOS-<version>.ipa`
4. Build FOSS-only Android — `Voyager-Android-<version>.apk`
5. Upload to the Apple App Store and Google Play Store
6. Create a Github Release with the artifacts
6. Deploy PWA to [beta.vger.app](https://beta.vger.app) (testing track) or [vger.app](https://vger.app) (release track)
7. Create a Github Release with the artifacts
#### several_days_later_spongebob_meme.jpg
In a few days, F-droid will scan the repo for new tags and [independently build](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/app.vger.voyager.yml) the FOSS-only Android native app. It will verify reproducibility against Github Releases, and then publish the app.
This is the main reason why each release tags trapeze changes (and build metadata) as a new commit. It also makes it easier for anyone to verify reproducibility.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

sync-upstream:
git switch main
git pull --all --prune
git merge upstream/main
10 changes: 0 additions & 10 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ export default tseslint.config(
"react-compiler/react-compiler": ["error", compilerOptions],
},
},
{
files: ["src/**"],

languageOptions: {
globals: {
APP_VERSION: true,
BUILD_FOSS_ONLY: true,
},
},
},
{
plugins: {
perfectionist: perfectionistPlugin,
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default_platform(:ios)

ENV['app_identifier'] = 'app.vger.voyager'
ENV['app_name_sanitized'] = 'App'
ENV['ios_output'] = "Voyager-iOS-#{ENV['APP_GIT_REF']}.ipa"
ENV['ios_output'] = "Voyager-iOS-#{ENV['BUILD_LABEL']}.ipa"

platform :ios do
before_all do
Expand Down
Loading

0 comments on commit f6542e7

Please sign in to comment.