Make sure the new tab URL is always valid #197
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Native CI/CD | |
on: | |
push: | |
paths: | |
- .github/workflows/native.yaml | |
- native/** | |
pull_request: | |
paths: | |
- .github/workflows/native.yaml | |
- native/** | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
clippy: | |
name: Clippy (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: native | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
- os: windows-latest | |
- os: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Configure Rust and Clippy | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: clippy | |
cache: false | |
- name: Configure cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: native | |
cache-on-failure: true | |
- name: Run Clippy | |
run: cargo clippy --all-targets --all-features -- -D warnings | |
rustfmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: native | |
shell: bash | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Configure Rust and Rustfmt | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: nightly | |
components: rustfmt | |
cache: false | |
- name: Configure cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: native | |
cache-on-failure: true | |
- name: Run Rustfmt | |
run: cargo fmt --all -- --check | |
build: | |
name: Build (${{ matrix.target }}) | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: native | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Normal builds for Linux | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: i686-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: armv7-unknown-linux-gnueabihf | |
# Normal builds for Windows | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: windows-latest | |
target: i686-pc-windows-msvc | |
# Portable builds for Windows | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
flags: --features portable | |
portable: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Configure Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
cache: false | |
- name: Configure cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
native | |
native/packages/paf/PWAsForFirefoxHelpers | |
cache-on-failure: true | |
cache-all-crates: true | |
key: ${{ matrix.target }}-${{ matrix.portable == true }} | |
- name: Install cross (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
# Use cross 0.2.4 for now because newer versions require too new glibc versions | |
# In the future, we should update cross and configure zig to link to older glibc | |
cargo install cross --git https://github.com/cross-rs/cross --rev 4645d937bdae6952d9df38eff3ecb91fd719c3bd | |
- name: Install Cargo DEB (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cargo install cargo-deb --git https://github.com/kornelski/cargo-deb.git --rev b4a659cfa8309275f80800793346e13c9e0ef806 | |
- name: Install Cargo RPM (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cargo install cargo-rpm --git https://github.com/iqlusioninc/cargo-rpm.git --rev ca2f28d012529914c59a1cc93edfd059bf294e21 | |
- name: Install Cargo WiX (Windows) | |
if: matrix.os == 'windows-latest' && matrix.portable != true | |
run: | | |
echo "C:\Program Files (x86)\WiX Toolset v3.11\bin" >> $GITHUB_PATH | |
cargo install cargo-wix --git https://github.com/volks73/cargo-wix.git --rev cc582226702a793fc9e1c20cdf99399663d6a2df | |
- name: Install PortableApps.com (Windows) | |
if: matrix.os == 'windows-latest' && matrix.portable == true | |
run: | | |
mkdir $TEMP/PortableAppsLauncher && cd $TEMP/PortableAppsLauncher | |
curl "https://download2.portableapps.com/portableapps/PortableApps.comLauncher/PortableApps.comLauncher_2.2.3.paf.exe" -o PortableAppsLauncher.paf.exe | |
7z x -y PortableAppsLauncher.paf.exe | |
echo $TEMP/PortableAppsLauncher >> $GITHUB_PATH | |
mkdir $TEMP/PortableAppsInstaller && cd $TEMP/PortableAppsInstaller | |
curl "https://download2.portableapps.com/portableapps/PortableApps.comInstaller/PortableApps.comInstaller_3.7.6.paf.exe" -o PortableAppsInstaller.paf.exe | |
7z x -y PortableAppsInstaller.paf.exe | |
echo $TEMP/PortableAppsInstaller >> $GITHUB_PATH | |
- name: Configure Linux builds | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
# Use vendored OpenSSL as dynamically-linked libraries are harder to use with cross | |
sed -i '/\[dependencies\]/a openssl = { version = "0.10", features = ["vendored"] }' Cargo.toml | |
# Replace completions paths with the correct paths for cross-compilation | |
sed -i 's/..\/target\/release\/completions\//..\/target\/${{ matrix.target }}\/release\/completions\//g' Cargo.toml | |
# Pin cross images to 0.2.4 as newer versions require too new glibc versions | |
printf '[target.x86_64-unknown-linux-gnu]\nimage = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.4"\n\n' >> Cross.toml | |
printf '[target.i686-unknown-linux-gnu]\nimage = "ghcr.io/cross-rs/i686-unknown-linux-gnu:0.2.4"\n\n' >> Cross.toml | |
printf '[target.aarch64-unknown-linux-gnu]\nimage = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.4"\n\n' >> Cross.toml | |
printf '[target.armv7-unknown-linux-gnueabihf]\nimage = "ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:0.2.4"\n\n' >> Cross.toml | |
# Manually specify minimum libc6 version as cargo-deb cannot determine it correctly when using cross | |
sed -i '/\[package.metadata.deb\]/a depends = "libc6 (>= 2.18)"' Cargo.toml | |
# Configure binutils for ARM targets | |
if [[ ${{ matrix.target }} == aarch64-* ]] || [[ ${{ matrix.target }} == armv7-* ]] | |
then | |
sudo apt-get update | |
sudo apt-get install binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf | |
mkdir -p .cargo && touch .cargo/config | |
printf '[target.aarch64-unknown-linux-gnu]\nstrip = { path = "aarch64-linux-gnu-strip" }\nobjcopy = { path = "aarch64-linux-gnu-objcopy" }\n\n' >> .cargo/config | |
printf '[target.armv7-unknown-linux-gnueabihf]\nstrip = { path = "arm-linux-gnueabihf-strip" }\nobjcopy = { path = "arm-linux-gnueabihf-objcopy" }\n' >> .cargo/config | |
fi | |
- name: Set the version | |
run: | | |
if [[ $GITHUB_REF == refs/tags/v* ]] | |
then | |
VERSION=${GITHUB_REF/refs\/tags\/v} | |
sed -i "s/version = \"0.0.0\"/version = \"$VERSION\"/g" Cargo.toml | |
sed -i "s/DISTRIBUTION_VERSION = '0.0.0'/DISTRIBUTION_VERSION = '$VERSION'/g" userchrome/profile/chrome/pwa/chrome.jsm | |
fi | |
- name: Build the project | |
run: | | |
[[ ${{ matrix.os }} == ubuntu-latest ]] && CARGO="cross" || CARGO="cargo" | |
$CARGO build --release --target ${{ matrix.target }} ${{ matrix.flags }} | |
- name: Package shell completions | |
if: matrix.target == 'x86_64-unknown-linux-gnu' | |
run: | | |
zip -rj target/completions.zip target/x86_64-unknown-linux-gnu/release/completions/* | |
- name: Package DEB (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cargo deb --verbose --no-build --target ${{ matrix.target }} | |
mkdir -p target/debian/ && cp -r target/${{ matrix.target }}/debian/*.deb target/debian/ | |
- name: Package RPM (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cargo rpm build --verbose --no-cargo-build --target ${{ matrix.target }} | |
- name: Package MSI (Windows) | |
if: matrix.os == 'windows-latest' && matrix.portable != true | |
run: | | |
heat dir userchrome -o packages/wix/userchrome.wxs -scom -srd -sreg -gg -cg UserChrome -dr UserChromeDir -var wix.UserChromeSource | |
cargo wix --verbose --no-build --nocapture --target ${{ matrix.target }} | |
- name: Package PAF (Windows) | |
if: matrix.os == 'windows-latest' && matrix.portable == true | |
run: | | |
# Build helper executables | |
echo "::group::Building helpers" | |
(cd packages/paf/PWAsForFirefoxHelpers && cargo build --release --target ${{ matrix.target }}) | |
echo "::endgroup::" | |
# Copy files to the portable app package | |
echo "::group::Copying files to the package" | |
mkdir -p packages/paf/PWAsForFirefoxPortable/App/PWAsForFirefox/ | |
cp target/${{ matrix.target }}/release/firefoxpwa.exe packages/paf/PWAsForFirefoxPortable/App/PWAsForFirefox/ | |
cp target/${{ matrix.target }}/release/firefoxpwa-connector.exe packages/paf/PWAsForFirefoxPortable/App/PWAsForFirefox/ | |
cp packages/paf/PWAsForFirefoxHelpers/target/${{ matrix.target }}/release/firefoxpwa-background.exe packages/paf/PWAsForFirefoxPortable/App/PWAsForFirefox/ | |
cp manifests/windows.json packages/paf/PWAsForFirefoxPortable/App/PWAsForFirefox/firefoxpwa.json | |
cp -r userchrome/ packages/paf/PWAsForFirefoxPortable/App/PWAsForFirefox/ | |
echo "::endgroup::" | |
# Set the package version | |
echo "::group::Setting the package versions" | |
if [[ $GITHUB_REF == refs/tags/v* ]] | |
then | |
VERSION=${GITHUB_REF/refs\/tags\/v} | |
sed -i "s/PackageVersion=0.0.0.0/PackageVersion=$VERSION.0/g" packages/paf/PWAsForFirefoxPortable/App/AppInfo/appinfo.ini | |
sed -i "s/DisplayVersion=0.0.0/DisplayVersion=$VERSION/g" packages/paf/PWAsForFirefoxPortable/App/AppInfo/appinfo.ini | |
else | |
VERSION=0.0.0 | |
fi | |
echo "::endgroup::" | |
# Generate the launcher and installer | |
echo "::group::Generating the launcher and installer" | |
cd packages/paf | |
PortableApps.comLauncherGenerator.exe $(cygpath -d $(realpath PWAsForFirefoxPortable)) | |
PortableApps.comInstaller.exe $(cygpath -d $(realpath PWAsForFirefoxPortable)) | |
echo "::endgroup::" | |
# Rename the installer | |
echo "::group::Renaming the installer" | |
mkdir -p ../../target/paf/ | |
mv PWAsForFirefoxPortable_*.paf.exe ../../target/paf/firefoxpwa_${VERSION}_online.paf.exe | |
echo "::endgroup::" | |
- name: Upload artifacts | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
path: | | |
native/target/completions.zip | |
native/target/debian/*.deb | |
native/target/rpm/*.rpm | |
native/target/wix/*.msi | |
native/target/paf/*.paf.exe | |
release-github: | |
name: Release on GitHub | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: | |
- clippy | |
- rustfmt | |
- build | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
- name: Upload artifacts to GitHub Release | |
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 | |
with: | |
fail_on_unmatched_files: true | |
files: | | |
artifact/completions.zip | |
artifact/debian/*.deb | |
artifact/rpm/*.rpm | |
artifact/wix/*.msi | |
artifact/paf/*.paf.exe | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
release-packagecloud: | |
name: Release on packagecloud.io | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: | |
- clippy | |
- rustfmt | |
- build | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
- name: Install packagecloud.io CLI | |
run: sudo gem install package_cloud | |
- name: Upload artifacts to packagecloud.io repositories | |
env: | |
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} | |
run: | | |
package_cloud push filips/FirefoxPWA/any/any artifact/debian/*.deb | |
package_cloud push filips/FirefoxPWA/rpm_any/rpm_any artifact/rpm/*.rpm | |
release-aur: | |
name: Release on Arch User Repository | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
container: archlinux | |
needs: | |
- release-github | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install required packages | |
run: pacman -Syu pacman-contrib pacman namcap sudo --noconfirm --needed | |
- name: Prepare non-root user | |
run: chown -R nobody . | |
- name: Update PKGBUILDs | |
run: | | |
echo "::group::Setting the package versions" | |
VERSION=${GITHUB_REF/refs\/tags\/v} | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
sed -i "s/pkgver=\$VERSION/pkgver=\"$VERSION\"/g" native/packages/aur/firefox-pwa/PKGBUILD | |
sed -i "s/pkgver=\$VERSION/pkgver=\"$VERSION\"/g" native/packages/aur/firefox-pwa-bin/PKGBUILD | |
echo "::endgroup::" | |
echo "::group::Updating the package checksums" | |
(cd native/packages/aur/firefox-pwa && sudo -u nobody updpkgsums) | |
(cd native/packages/aur/firefox-pwa-bin && sudo -u nobody updpkgsums) | |
echo "::endgroup::" | |
- name: Verify PKGBUILDs | |
run: | | |
# Binary version is skipped because namcap doesn't work with arch-specific sources | |
(cd native/packages/aur/firefox-pwa && namcap -i PKGBUILD) | |
- name: Release firefox-pwa package | |
uses: KSXGitHub/github-actions-deploy-aur@065b6056b25bdd43830d5a3f01899d0ff7169819 | |
with: | |
pkgname: firefox-pwa | |
pkgbuild: ./native/packages/aur/firefox-pwa/PKGBUILD | |
assets: ./native/packages/aur/firefox-pwa/** | |
commit_message: Update to ${{ env.VERSION }} | |
commit_username: ${{ secrets.AUR_USERNAME }} | |
commit_email: ${{ secrets.AUR_EMAIL }} | |
ssh_private_key: ${{ secrets.AUR_PRIVATE_KEY }} | |
ssh_keyscan_types: rsa,dsa,ecdsa,ed25519 | |
- name: Release firefox-pwa-bin package | |
uses: KSXGitHub/github-actions-deploy-aur@065b6056b25bdd43830d5a3f01899d0ff7169819 | |
with: | |
pkgname: firefox-pwa-bin | |
pkgbuild: ./native/packages/aur/firefox-pwa-bin/PKGBUILD | |
assets: ./native/packages/aur/firefox-pwa-bin/** | |
commit_message: Update to ${{ env.VERSION }} | |
commit_username: ${{ secrets.AUR_USERNAME }} | |
commit_email: ${{ secrets.AUR_EMAIL }} | |
ssh_private_key: ${{ secrets.AUR_PRIVATE_KEY }} | |
ssh_keyscan_types: rsa,dsa,ecdsa,ed25519 | |
release-winget: | |
name: Release on Windows Package Manager | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: windows-latest | |
needs: | |
- release-github | |
steps: | |
- name: Install winget-create | |
shell: powershell | |
run: iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe | |
- name: Prepare Git user | |
run: | | |
git config --global user.name "${{ secrets.GH_USERNAME }}" | |
git config --global user.email "${{ secrets.GH_EMAIL }}" | |
- name: Update and release package manifest | |
run: | | |
VERSION=${GITHUB_REF/refs\/tags\/v} | |
INSTALLER_64BIT="https://github.com/filips123/PWAsForFirefox/releases/download/v$VERSION/firefoxpwa-$VERSION-x86_64.msi" | |
INSTALLER_32BIT="https://github.com/filips123/PWAsForFirefox/releases/download/v$VERSION/firefoxpwa-$VERSION-x86.msi" | |
./wingetcreate.exe update -s filips.FirefoxPWA -u $INSTALLER_64BIT $INSTALLER_32BIT -v $VERSION -t ${{ secrets.GH_TOKEN }} | |
release-chocolatey: | |
name: Release on Chocolatey | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: windows-latest | |
needs: | |
- release-github | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
- name: Calculate version and installer checksums | |
run: | | |
echo "::group::Copying installers to the package" | |
cp -R artifact/wix/*.msi native/packages/choco/tools/ | |
echo "::endgroup::" | |
echo "::group::Setting the package version" | |
VERSION=${GITHUB_REF/refs\/tags\/v} | |
sed -i "s/{{PackageVersion}}/$VERSION/g" native/packages/choco/firefoxpwa.nuspec | |
echo "::endgroup::" | |
echo "::group::Updating installer checksums" | |
cd native/packages/choco/tools/ | |
echo "$(sha256sum *.msi --tag)" >> ../legal/VERIFICATION.txt | |
echo "::endgroup::" | |
- name: Prepare Chocolatey package | |
run: | | |
cd native/packages/choco/ | |
choco pack | |
- name: Release Chocolatey package | |
run: choco push native/packages/choco/*.nupkg --source https://push.chocolatey.org/ --key ${{secrets.CHOCO_TOKEN}} | |
release-homebrew: | |
name: Release on Homebrew | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: macos-latest | |
needs: | |
- release-github | |
steps: | |
- name: Prepare Git user | |
run: | | |
git config --global user.name "${{ secrets.GH_USERNAME }}" | |
git config --global user.email "${{ secrets.GH_EMAIL }}" | |
- name: Update and release Homebrew formula | |
env: | |
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
VERSION=${GITHUB_REF/refs\/tags\/v} | |
brew update | |
brew bump-formula-pr --no-browse --strict --online --version $VERSION firefoxpwa |