Skip to content

Commit 46329f9

Browse files
committed
Configure GitHub Actions for snapshot builds
Automated snapshots are now built using GitHub Actions instead of Travis CI. For the time being, they are available at https://tho-otto.de/snapshots/ (this may change)
1 parent e68b1d5 commit 46329f9

File tree

7 files changed

+181
-1
lines changed

7 files changed

+181
-1
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Linux build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Install SSH keys
15+
env:
16+
SSH_ID: ${{ secrets.SSH_ID }}
17+
run: ./.scripts/install_ssh_id.sh
18+
- name: Install packages
19+
run: |
20+
SYSROOT_DIR="/" ./.scripts/install-freemint.sh binutils gcc mintbin
21+
./.scripts/install-freemint.sh mintlib
22+
- name: Setup environment
23+
env:
24+
PROJECT_VERSION: "0.44.0"
25+
run: ./.scripts/setup_env.sh
26+
- name: build
27+
run: ./.scripts/build.sh
28+
- name: deploy
29+
if: ${{ github.event_name == 'push' }}
30+
env:
31+
COMMITER_NAME: ${{ github.event.commits[0].author.name }}
32+
COMMITER_EMAIL: ${{ github.event.commits[0].author.email }}
33+
run: ./.scripts/deploy.sh

.scripts/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash -eux
2+
# -e: Exit immediately if a command exits with a non-zero status.
3+
# -u: Treat unset variables as an error when substituting.
4+
# -x: Display expanded script commands
5+
6+
make && make PREFIX="${INSTALL_DIR}" install
7+
8+
find "${INSTALL_DIR}" -type f \( -name '*.a' -o -name '*.o' \) -exec m68k-atari-mint-strip -S -X -w -N '.L[0-9]*' {} \;

.scripts/deploy.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh -ex
2+
3+
[email protected]:/home/www/snapshots
4+
5+
if [ -z "${DEPLOY_ARCHIVE+x}" ]
6+
then
7+
# zip is default
8+
DEPLOY_ARCHIVE="zip"
9+
fi
10+
11+
if [ -n "${CPU_TARGET+x}" ]
12+
then
13+
ARCHIVE_NAME="${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID}-${CPU_TARGET}.${DEPLOY_ARCHIVE}"
14+
else
15+
ARCHIVE_NAME="${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID}.${DEPLOY_ARCHIVE}"
16+
fi
17+
ARCHIVE_PATH="${DEPLOY_DIR}/${ARCHIVE_NAME}"
18+
19+
mkdir -p "${DEPLOY_DIR}"
20+
21+
if [ "${DEPLOY_ARCHIVE}" = "tar.bz2" ]
22+
then
23+
cd ${INSTALL_DIR} && tar cjf ${ARCHIVE_PATH} *
24+
elif [ "${DEPLOY_ARCHIVE}" = "tar.xz" ]
25+
then
26+
cd ${INSTALL_DIR} && tar cJf ${ARCHIVE_PATH} *
27+
elif [ "${DEPLOY_ARCHIVE}" = "tar.gz" ]
28+
then
29+
cd ${INSTALL_DIR} && tar czf ${ARCHIVE_PATH} *
30+
else
31+
cd $(dirname ${INSTALL_DIR}) && zip -r -9 ${ARCHIVE_PATH} $(basename ${INSTALL_DIR})
32+
fi
33+
34+
cd -
35+
36+
37+
eval "$(ssh-agent -s)"
38+
39+
PROJECT_DIR="$PROJECT_NAME"
40+
case $PROJECT_DIR in
41+
m68k-atari-mint-gcc) PROJECT_DIR=gcc ;;
42+
m68k-atari-mint-binutils-gdb) PROJECT_DIR=binutils ;;
43+
esac
44+
45+
scp -o "StrictHostKeyChecking no" "$ARCHIVE_PATH" "${UPLOAD_DIR}/${PROJECT_DIR}/${ARCHIVE_NAME}"
46+
if test -z "${CPU_TARGET}"
47+
then
48+
scp -o "StrictHostKeyChecking no" "$ARCHIVE_PATH" "${UPLOAD_DIR}/${PROJECT_DIR}/${PROJECT_DIR}-latest.${DEPLOY_ARCHIVE}"
49+
fi
50+
51+
echo ${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID} > .latest_version
52+
scp -o "StrictHostKeyChecking no" .latest_version "${UPLOAD_DIR}/${PROJECT_DIR}/.latest_version"

.scripts/install-freemint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash -eux
2+
# -e: Exit immediately if a command exits with a non-zero status.
3+
# -u: Treat unset variables as an error when substituting.
4+
# -x: Display expanded script commands
5+
6+
DOWNLOAD_DIR=http://tho-otto.de/snapshots
7+
SYSROOT_DIR=${SYSROOT_DIR:-"/usr/m68k-atari-mint/sys-root/usr"}
8+
9+
sudo mkdir -p "${SYSROOT_DIR}" && cd "${SYSROOT_DIR}"
10+
11+
for package in $*
12+
do
13+
wget -q -O - "$DOWNLOAD_DIR/${package}/${package}-latest.tar.bz2" | sudo tar xjf -
14+
done

.scripts/install_ssh_id.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash -eu
2+
# -e: Exit immediately if a command exits with a non-zero status.
3+
# -u: Treat unset variables as an error when substituting.
4+
5+
# This installs an SSH private/public key pair on the build system,
6+
# so ssh can connect to remote servers without password.
7+
# Important: for passwordless connection to succeed, our public key must be
8+
# manually authorized on the remote server.
9+
10+
# Our private key is the critical security component, it must remain secret.
11+
# We store it in the SSH_ID environment variable in Travis CI project settings.
12+
# As environment variables can only contain text, our key files are transformed
13+
# like this: tar, xz, base64. Then then can be decoded here. This is safe as
14+
# Travis CI never shows the contents of secure variables.
15+
16+
# To generate the contents of the SSH_ID variable:
17+
# Be sure to be in an empty, temporary directory.
18+
#
19+
# mkdir .ssh
20+
# ssh-keygen -t rsa -b 4096 -C travis-ci.org/$USER/$PROJECT -N '' -f .ssh/id_rsa
21+
# tar Jcvf id.tar.xz .ssh
22+
# base64 -w 0 id.tar.xz
23+
#
24+
# Select the resulting encoded text (several lines) to copy it to the clipboard.
25+
# Then go to the Travis CI project settings:
26+
# https://travis-ci.org/$USER/$PROJECT/settings
27+
# Create a new environment variable named SSH_ID, and paste the value.
28+
# The script below will recreate the key files from that variable contents.
29+
30+
if [ -z ${SSH_ID+x} ]
31+
then
32+
echo "error: SSH_ID is undefined" >&2
33+
exit 1
34+
fi
35+
36+
echo $SSH_ID | base64 -d | tar -C ~ -Jx
37+
38+
ls -l ~/.ssh

.scripts/setup_env.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
# Use as: ". setup_env.sh"
3+
4+
PROJECT_REPO=$(echo "${GITHUB_REPOSITORY}" | cut -d '/' -f 1)
5+
echo "PROJECT_REPO=${PROJECT_REPO}" >> $GITHUB_ENV
6+
PROJECT_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d '/' -f 2)
7+
echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV
8+
# PROJECT_VERSION is defined in the action script
9+
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV
10+
INSTALL_DIR="/tmp/${PROJECT_NAME}"
11+
echo "INSTALL_DIR=${INSTALL_DIR}" >> $GITHUB_ENV
12+
DEPLOY_DIR="/tmp/${PROJECT_NAME}-deploy"
13+
echo "DEPLOY_DIR=${DEPLOY_DIR}" >> $GITHUB_ENV
14+
DEPLOY_ARCHIVE="tar.bz2"
15+
echo "DEPLOY_ARCHIVE=${DEPLOY_ARCHIVE}" >> $GITHUB_ENV
16+
17+
SHORT_ID=$(echo ${GITHUB_SHA} | cut -c 1-3)
18+
echo "SHORT_ID=$SHORT_ID" >> $GITHUB_ENV
19+
LONG_ID=$(echo ${GITHUB_SHA} | cut -c 1-8)
20+
echo "LONG_ID=$LONG_ID" >> $GITHUB_ENV
21+
BRANCH=$(echo "${GITHUB_REF}" | cut -d '/' -f 3)
22+
23+
if test "$CPU_TARGET" != ""; then
24+
echo "CPU_TARGET=$CPU_TARGET" >> $GITHUB_ENV
25+
fi
26+
27+
# GITHUB_HEAD_REF is only set for pull requests
28+
if [ "${GITHUB_HEAD_REF}" = "" ]
29+
then
30+
COMMIT_MESSAGE="[${PROJECT_NAME}] [${BRANCH}] Commit: https://github.com/${PROJECT_REPO}/${PROJECT_NAME}/commit/${GITHUB_SHA}"
31+
fi
32+
33+
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
[![Build Status](https://travis-ci.org/freemint/gemlib.svg?branch=master)](https://travis-ci.org/freemint/gemlib) [ ![Download](https://api.bintray.com/packages/freemint/lib/gemlib/images/download.svg) ](https://bintray.com/freemint/lib/gemlib/_latestVersion)
1+
[![Build Status](https://github.com/freemint/gemlib/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/freemint/gemlib/actions)
2+
3+
Latest snapshot: [Download](https://tho-otto.de/snapshots/gemlib/gemlib-latest.tar.bz2)

0 commit comments

Comments
 (0)