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 13, 2024
2 parents 33b282d + 6ec93e4 commit d5fa3c9
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 95 deletions.
71 changes: 47 additions & 24 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
name: Build, deploy and release
name: build_release

on:
workflow_call: # for beta releases from main - release.yml / dispatch_beta_release
inputs:
is_main_build:
type: boolean
required: true
app_build:
type: string
required: true
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "test-[0-9]+.[0-9]+.[0-9]+"

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

concurrency:
group: release

jobs:
build_web:
runs-on: ubuntu-latest
concurrency:
group: "build_web"
steps:
- uses: actions/checkout@v4

Expand All @@ -27,7 +39,7 @@ jobs:
run: pnpm build

- name: Upload dist bundle to S3
if: github.ref_name != 'test*'
if: inputs.is_main_build != true
uses: jakejarvis/s3-sync-action@v0.5.1
with:
args: --acl public-read --follow-symlinks --delete
Expand All @@ -39,23 +51,26 @@ jobs:

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

build_ios:
environment: deploy
runs-on: macos-latest
concurrency:
group: "build_ios"
cancel-in-progress: true
steps:
- uses: actions/checkout@v4

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

- uses: actions/setup-node@v4
with:
node-version: 22
Expand Down Expand Up @@ -84,7 +99,6 @@ jobs:
CI_PLATFORM: ios

- name: Deploy to TestFlight
if: github.ref_name != 'test*'
run: |
echo "$APP_STORE_CONNECT_KEY" > authkey.json
bundle exec fastlane deploy
Expand All @@ -98,14 +112,20 @@ jobs:
- name: Upload iOS IPA as artifact
uses: actions/upload-artifact@v4
with:
name: Voyager-iOS-${{ github.ref_name }}.ipa
path: Voyager-iOS-${{ github.ref_name }}.ipa
name: Voyager-iOS-${{ env.APP_GIT_REF }}.ipa
path: Voyager-iOS-${{ env.APP_GIT_REF }}.ipa

build_android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- uses: actions/setup-node@v4
with:
node-version: 22
Expand Down Expand Up @@ -135,23 +155,26 @@ 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-${{ github.ref_name }}.apk
- run: mv android/app/build/outputs/apk/release/app-release.apk Voyager-Android-${{ env.APP_GIT_REF }}.apk

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

build_android_play:
environment: deploy
runs-on: ubuntu-latest
concurrency:
group: "build_android_play"
cancel-in-progress: true
steps:
- uses: actions/checkout@v4

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

- uses: actions/setup-node@v4
with:
node-version: 22
Expand Down Expand Up @@ -200,7 +223,7 @@ jobs:

create_release:
needs: [build_web, build_ios, build_android_play, build_android]
if: startsWith(github.ref_name, 'test-') != true
if: inputs.is_main_build != true
runs-on: ubuntu-latest

permissions:
Expand All @@ -210,19 +233,19 @@ jobs:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: Voyager-Web-${{ github.ref_name }}.zip
name: Voyager-Web-${{ env.APP_GIT_REF }}.zip
path: artifacts/web

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

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

- name: Release
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: build & push docker container
name: docker

on:
push:
branches:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Run e2e tests
name: e2e

on: workflow_dispatch
jobs:
playwright:
name: Run Playwright tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
93 changes: 65 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
name: Cut a release
name: release

on:
workflow_dispatch:
# -- TESTING ONLY --
# push:
# branches:
# - inherit # todo remove, can't workflow_dispatch from branch
inputs:
release_behavior:
description: "If publish_release, will create a release and publish it to the release branch. If push_beta, will create a beta build and push it to the beta track."
required: true
default: "publish_release"
type: choice
options:
- publish_release
- push_beta
push:
branches:
- "main"

env:
APP_BUILD_OFFSET: 300
TAG_PREFIX: # test-
RELEASE_BRANCH_PREFIX: release # test-release

jobs:
app_build_number:
name: Calculate app build number
app_build:
runs-on: ubuntu-latest
steps:
- id: calculate
Expand All @@ -25,12 +30,10 @@ jobs:
outputs:
app_build: ${{ steps.calculate.outputs.app_build }}

validate_version:
needs: app_build_number
name: Validate version
app_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_current_version.outputs.version }}
app_version: ${{ steps.app_version.outputs.app_version }}
steps:
- uses: actions/checkout@v4

Expand All @@ -39,29 +42,27 @@ jobs:
node-version: 22

- name: Get current version from package.json
id: get_current_version
id: app_version
run: |
CURRENT_APP_VERSION=$(node -p "require('./package.json').version")
echo "version=$CURRENT_APP_VERSION" >> $GITHUB_OUTPUT
echo "app_version=$CURRENT_APP_VERSION" >> $GITHUB_OUTPUT
- name: Verify provided version not already released
if: inputs.release_behavior == 'publish_release'
run: |
git fetch --tags
TAG_NAME="$TAG_PREFIX${{ steps.get_current_version.outputs.version }}"
TAG_NAME="${{ steps.app_version.outputs.app_version }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Error: Tag $TAG_NAME already exists"
exit 1
fi
push_release:
needs: [validate_version, app_build_number]
name: Add version to apps, push release branch and tag
bump_src:
needs: [app_build, app_version]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # Don't clobber the PAT below

- run: corepack enable

Expand All @@ -71,8 +72,43 @@ jobs:
- name: Run trapeze (update iOS and Android version/code)
run: pnpm exec trapeze run trapeze.yaml -y
env:
APP_BUILD: ${{ needs.app_build_number.outputs.app_build }}
APP_VERSION: ${{ needs.validate_version.outputs.version }}
APP_BUILD: ${{ needs.app_build.outputs.app_build }}
APP_VERSION: ${{ needs.app_version.outputs.app_version }}

- name: Upload bumped version artifacts
uses: actions/upload-artifact@v4
with:
name: trapeze-artifacts
retention-days: 3
path: |
android
ios
dispatch_beta_release:
if: inputs.release_behavior != 'publish_release'
needs: [app_build, 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

push_release:
needs: [bump_src, app_build, app_version]
runs-on: ubuntu-latest
if: inputs.release_behavior == 'publish_release'

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # Don't clobber the PAT below

- name: Download bumped version artifacts
uses: actions/download-artifact@v4
with:
name: trapeze-artifacts

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
Expand All @@ -81,20 +117,21 @@ jobs:
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true

- name: Commit and push release
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
# 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_BRANCH_PREFIX/${{ needs.validate_version.outputs.version }}"
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.validate_version.outputs.version }} (${{ needs.app_build_number.outputs.app_build }})"
TAG_NAME="${TAG_PREFIX}${{ needs.validate_version.outputs.version }}"
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 "$TAG_NAME"
git push origin "$RELEASE_BRANCH_PREFIX/${{ needs.validate_version.outputs.version }}"
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"
24 changes: 24 additions & 0 deletions .github/workflows/semantic_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: semantic_pull_request

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
if: github.repository == 'aeharding/voyager'
runs-on: ubuntu-latest
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5
with:
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"recommendations": [
"ionic.ionic",
"esbenp.prettier-vscode",
"styled-components.vscode-styled-components"
"styled-components.vscode-styled-components",
"github.vscode-github-actions"
]
}
4 changes: 2 additions & 2 deletions e2e/community-feed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test("load community posts", async ({ page }) => {

await expect(page).toHaveTitle("Voyager for Lemmy");

await expect(page.getByText(posts[0].post.name)).toBeVisible();
await expect(page.getByText(posts[0]!.post.name)).toBeVisible();
});

test("navigate to post on click", async ({ page }) => {
Expand All @@ -22,7 +22,7 @@ test("navigate to post on click", async ({ page }) => {

await page.goto("/");

await page.getByText(posts[0].post.name).click();
await page.getByText(posts[0]!.post.name).click();

await expect(page).toHaveURL(
"/posts/lemmy.world/c/community_1@test.lemmy/comments/999",
Expand Down
Loading

0 comments on commit d5fa3c9

Please sign in to comment.