Skip to content

Commit

Permalink
Support reproducible builds (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
frimtec authored Sep 9, 2024
1 parent d1158e2 commit 00810e3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 26 deletions.
44 changes: 20 additions & 24 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ jobs:

runs-on: ubuntu-22.04

outputs:
VCODE: ${{ steps.get_vcode.outputs.VCODE }}

steps:
- uses: actions/checkout@v4

Expand All @@ -21,29 +18,17 @@ jobs:
distribution: 'zulu'
java-version: 17

- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT

- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Set version
run: |
sed -i 's/$version/${{ steps.get_version.outputs.VERSION }}/g' app/version.properties
- name: Get VCODE
id: get_vcode
run: echo "VCODE=$(expr $(date +%s) / 60 - 26797800)" >> $GITHUB_OUTPUT

- name: Build APK
run: bash ./gradlew assembleRelease --stacktrace -Dversion.code=${{ steps.get_vcode.outputs.VCODE }} -Dpurchase.validation.key=${{ secrets.PURCHASE_VALIDATION_KEY }}
run: bash ./gradlew assembleRelease --stacktrace -Dpurchase.validation.key=${{ secrets.PURCHASE_VALIDATION_KEY }}

- name: Build AAB
run: bash ./gradlew :app:bundleRelease --stacktrace -Dversion.code=${{ steps.get_vcode.outputs.VCODE }} -Dpurchase.validation.key=${{ secrets.PURCHASE_VALIDATION_KEY }}
run: bash ./gradlew :app:bundleRelease --stacktrace -Dpurchase.validation.key=${{ secrets.PURCHASE_VALIDATION_KEY }}

- name: Setup build tool version variable
shell: bash
Expand Down Expand Up @@ -120,11 +105,22 @@ jobs:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
- name: Checkout release/next branch
run: |
git checkout release/next
- name: Checkout master
- name: Read version.properties
id: read_version_properties
run: |
while IFS='=' read -r key value; do
if [ "$key" ]; then
echo "$key=$value"
# Set as environment variable
echo "$key=$value" >> $GITHUB_OUTPUT
fi
done < app/version.properties
- name: Checkout master branch
run: |
git checkout master
Expand All @@ -137,15 +133,15 @@ jobs:
- name: Create fastlane changelog
run: |
mkdir -p fastlane/metadata/android/en-US/changelogs
echo "${{ steps.get_release.outputs.body }}" | sed '/^-/!d;s/- #[[:digit:]]\+ \(.*\) @\(.*\)/- \1/g' | head -n 10 >> fastlane/metadata/android/en-US/changelogs/${{needs.deploy.outputs.VCODE}}.txt
echo "${{ steps.get_release.outputs.body }}" | sed '/^-/!d;s/- #[[:digit:]]\+ \(.*\) @\(.*\)/- \1/g' | head -n 10 >> fastlane/metadata/android/en-US/changelogs/${{ steps.read_version_properties.outputs.VERSION_CODE }}.txt
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add fastlane/metadata/android/en-US/changelogs/${{needs.deploy.outputs.VCODE}}.txt
git commit -m "Update release changelog for ${{ steps.get_version.outputs.VERSION }}"
git add fastlane/metadata/android/en-US/changelogs/${{ steps.read_version_properties.outputs.VERSION_CODE }}.txt
git commit -m "Update release changelog for ${{ steps.read_version_properties.outputs.VERSION_NAME }}"
- name: Push changes
uses: ad-m/[email protected]
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,43 @@ on:
jobs:
update_release_draft:
name: ✏️ Draft release
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-22.04

steps:
- name: 🚀 Run Release Drafter
id: release_drafter
uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v4

- name: Generate VCODE
id: generate_vcode
run: echo "vcode=$(expr $(date +%s) / 60 - 26797800)" >> $GITHUB_OUTPUT

- name: Set version
run: |
sed -i 's/$version/${{ steps.release_drafter.outputs.name }}/g' app/version.properties
sed -i 's/$code/${{ steps.generate_vcode.outputs.vcode }}/g' app/version.properties
- name: Commit version
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Configure release information
branch: release/next
create_branch: true
push_options: '--force'

- name: Change target
run: |
curl -X PATCH \
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Content-Type: application/json' \
"https://api.github.com/repos/frimtec/pikett-assist/releases/${{ steps.release_drafter.outputs.id }}" \
-d '{"tag_name": "${{ steps.release_drafter.outputs.name }}", "target_commitish": "refs/heads/release/next"}'
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (versionPropsFile.exists()) {
versionProps.load(new FileInputStream(versionPropsFile))
}

int vcode = Integer.parseInt(System.getProperty("version.code", String.valueOf((int) ((System.currentTimeMillis() / 1000 / 60) - 26_797_800))))
int vcode = Integer.parseInt((versionProps['VERSION_CODE'] == null || versionProps['VERSION_CODE'].startsWith('$')) ? String.valueOf((int) ((System.currentTimeMillis() / 1000 / 60) - 26_797_800)) : versionProps['VERSION_CODE'])
String vname = (versionProps['VERSION_NAME'] == null || versionProps['VERSION_NAME'].startsWith('$')) ? '0.0.0' : versionProps['VERSION_NAME']

def purchaseValidationKeyProperties = new Properties()
Expand Down
3 changes: 2 additions & 1 deletion app/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VERSION_NAME=$version-Roboto
VERSION_NAME=$version
VERSION_CODE=$code

0 comments on commit 00810e3

Please sign in to comment.