Skip to content

Commit a1eae06

Browse files
committed
Add a github workflow for snapshots
1 parent 42a73ab commit a1eae06

7 files changed

Lines changed: 218 additions & 1 deletion

File tree

‎.github/workflows/build.yml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Linux build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
branches: [ master ]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-22.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
cross_tool: [ "m68k-atari-mint", "m68k-atari-mintelf" ]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install SSH keys
21+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
22+
env:
23+
SSH_ID: ${{ secrets.SSH_ID }}
24+
run: ./.scripts/install_ssh_id.sh
25+
- name: Setup environment
26+
env:
27+
PROJECT_VERSION: "0.55"
28+
CROSS_TOOL: ${{ matrix.cross_tool }}
29+
run: ./.scripts/setup_env.sh
30+
- name: Install packages
31+
run: |
32+
SYSROOT_DIR="/" ./.scripts/install-freemint.sh binutils gcc mintbin
33+
./.scripts/install-freemint.sh mintlib fdlibm gemlib
34+
- name: build
35+
run: ./.scripts/build.sh
36+
- name: deploy
37+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
38+
env:
39+
COMMITER_NAME: ${{ github.event.commits[0].author.name }}
40+
COMMITER_EMAIL: ${{ github.event.commits[0].author.email }}
41+
run: ./.scripts/deploy.sh

‎.scripts/build.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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 DESTDIR=${INSTALL_DIR} install

‎.scripts/deploy.sh‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/sh -x
2+
3+
SERVER=web196@server43.webgo24.de
4+
UPLOAD_DIR=$SERVER:/home/www/snapshots
5+
6+
if [ -z "${DEPLOY_ARCHIVE+x}" ]
7+
then
8+
# zip is default
9+
DEPLOY_ARCHIVE="zip"
10+
fi
11+
12+
toolsuffix=${CROSS_TOOL##*-}
13+
14+
ARCHIVE_NAME="${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID}-${toolsuffix}.${DEPLOY_ARCHIVE}"
15+
ARCHIVE_PATH="${DEPLOY_DIR}/${ARCHIVE_NAME}"
16+
17+
mkdir -p "${DEPLOY_DIR}"
18+
19+
if [ "${DEPLOY_ARCHIVE}" = "tar.bz2" ]
20+
then
21+
cd ${INSTALL_DIR} && tar cjf ${ARCHIVE_PATH} *
22+
elif [ "${DEPLOY_ARCHIVE}" = "tar.xz" ]
23+
then
24+
cd ${INSTALL_DIR} && tar cJf ${ARCHIVE_PATH} *
25+
elif [ "${DEPLOY_ARCHIVE}" = "tar.gz" ]
26+
then
27+
cd ${INSTALL_DIR} && tar czf ${ARCHIVE_PATH} *
28+
else
29+
cd $(dirname ${INSTALL_DIR}) && zip -r -9 ${ARCHIVE_PATH} $(basename ${INSTALL_DIR})
30+
fi
31+
32+
cd -
33+
34+
35+
eval "$(ssh-agent -s)"
36+
37+
PROJECT_DIR="$PROJECT_NAME"
38+
case $PROJECT_DIR in
39+
m68k-atari-mint-gcc) PROJECT_DIR=gcc ;;
40+
m68k-atari-mint-binutils-gdb) PROJECT_DIR=binutils ;;
41+
esac
42+
43+
upload_file() {
44+
local from="$1"
45+
local to="$2"
46+
for i in 1 2 3
47+
do
48+
scp -o "StrictHostKeyChecking no" "$from" "$to"
49+
[ $? = 0 ] && return 0
50+
sleep 1
51+
done
52+
exit 1
53+
}
54+
55+
link_file() {
56+
local from="$1"
57+
local to="$2"
58+
for i in 1 2 3
59+
do
60+
ssh -o "StrictHostKeyChecking no" $SERVER -- "cd www/snapshots/${PROJECT_DIR}; ln -sf $from $to"
61+
[ $? = 0 ] && return 0
62+
sleep 1
63+
done
64+
exit 1
65+
}
66+
67+
upload_file "$ARCHIVE_PATH" "${UPLOAD_DIR}/${PROJECT_DIR}/${ARCHIVE_NAME}"
68+
link_file "$ARCHIVE_NAME" "${PROJECT_DIR}-${toolsuffix}-latest.${DEPLOY_ARCHIVE}"
69+
70+
echo ${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID} > .latest_version
71+
upload_file .latest_version "${UPLOAD_DIR}/${PROJECT_DIR}/.latest_version"

‎.scripts/install-freemint.sh‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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/${CROSS_TOOL}/sys-root"}
8+
9+
sudo mkdir -p "${SYSROOT_DIR}" && cd "${SYSROOT_DIR}"
10+
11+
toolsuffix=${CROSS_TOOL##*-}
12+
13+
for package in $*
14+
do
15+
# for gcc and binutils, use stable current, not experimental latest build
16+
case $package in
17+
gcc | binutils)
18+
filename=${package}-${toolsuffix}-current.tar.bz2
19+
;;
20+
*)
21+
filename=${package}-${toolsuffix}-latest.tar.bz2
22+
;;
23+
esac
24+
wget -q -O - "$DOWNLOAD_DIR/${package}/${filename}" | sudo tar xjf -
25+
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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
CROSS_TOOL=${CROSS_TOOL:-m68k-atari-mint}
24+
echo "CROSS_TOOL=$CROSS_TOOL" >> $GITHUB_ENV
25+
26+
# GITHUB_HEAD_REF is only set for pull requests
27+
if [ "${GITHUB_HEAD_REF}" = "" ]
28+
then
29+
COMMIT_MESSAGE="[${PROJECT_NAME}] [${BRANCH}] Commit: https://github.com/${PROJECT_REPO}/${PROJECT_NAME}/commit/${GITHUB_SHA}"
30+
fi
31+
32+
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV

‎README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
[![Build Status](https://travis-ci.org/freemint/libcmini.svg?branch=master)](https://travis-ci.org/freemint/libcmini)
1+
[![Build Status](https://github.com/freemint/libcmini/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/freemint/libcmini/actions)
2+
3+
* Latest snapshot: [Download (mint)](https://tho-otto.de/snapshots/libcmini/libcmini-mint-latest.tar.bz2)
4+
* Latest snapshot: [Download (mintelf)](https://tho-otto.de/snapshots/libcmini/libcmini-mintelf-latest.tar.bz2)
5+
* [Archive](https://tho-otto.de/snapshots/libcmini/)
26

37
# libcmini
48

0 commit comments

Comments
 (0)