-
-
Save adam-stokes/edac1dfa4c15eb85b18ddfe3c047adbc to your computer and use it in GitHub Desktop.
Automatically publish to the snap store from Travis
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
#!/bin/sh -e | |
if [ -z "$SNAPCRAFT_SECRET" ]; then | |
exit 0 | |
fi | |
mkdir -p ".encrypted" | |
if [ ! -e ".encrypted/snapcraft.cfg.enc" ]; then | |
echo "Seeding a new macaroon." | |
echo "$SNAPCRAFT_CONFIG" > ".encrypted/snapcraft.cfg.enc" | |
fi | |
mkdir -p "$HOME/.config/snapcraft" | |
openssl enc -aes-256-cbc -base64 -pass env:SNAPCRAFT_SECRET -d -in ".encrypted/snapcraft.cfg.enc" -out "$HOME/.config/snapcraft/snapcraft.cfg" | |
if docker run -v $HOME:/root -v $(pwd):/cwd didrocks/snapcraft sh -c 'cd /cwd; snapcraft'; then | |
if [ "${TRAVIS_BRANCH}" = "edge" ]; then | |
docker run -v $HOME:/root -v $(pwd):/cwd didrocks/snapcraft sh -c "cd /cwd; snapcraft push *.snap --release edge" | |
elif [ "${TRAVIS_BRANCH}" = "master" ]; then | |
docker run -v $HOME:/root -v $(pwd):/cwd didrocks/snapcraft sh -c "cd /cwd; snapcraft push *.snap --release stable" | |
fi | |
fi | |
openssl enc -aes-256-cbc -base64 -pass env:SNAPCRAFT_SECRET -out ".encrypted/snapcraft.cfg.enc" < "$HOME/.config/snapcraft/snapcraft.cfg" | |
rm -f "$HOME/.config/snapcraft/snapcraft.cfg" |
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
sudo: required | |
dist: trusty | |
services: | |
- docker | |
cache: | |
directories: | |
- .encrypted | |
script: | |
- ./.travis.sh |
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
export SNAPCRAFT_SECRET=$(pwgen 20 -1) | |
export SNAPCRAFT_CONFIG="$(openssl enc -aes-256-cbc -base64 -pass env:SNAPCRAFT_SECRET < ~/.config/snapcraft/snapcraft.cfg)" | |
travis encrypt SNAPCRAFT_SECRET=$SNAPCRAFT_SECRET -a | |
travis env set SNAPCRAFT_CONFIG "$SNAPCRAFT_CONFIG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment