Files
eveship.fit.data/.github/workflows/release.yml
2024-05-05 16:35:22 +02:00

100 lines
3.0 KiB
YAML

name: Release
on:
release:
types:
- published
jobs:
datafiles:
name: Publish datafiles
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
registry-url: https://npm.pkg.github.com
scope: "@eveshipfit"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
run: |
# Remove the "v" from the version.
VERSION=$(echo ${{ github.ref_name }} | cut -b2-)
echo "Version: ${VERSION}"
sed -i 's/"version": "0.0.0-git"/"version": "'${VERSION}'"/' package.json
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends rclone protobuf-compiler
pip install -r requirements.txt
npm install
- name: Setup rclone
run: |
mkdir -p ~/.config/rclone
echo "[eveshipfit]" > ~/.config/rclone/rclone.conf
echo "type = s3" >> ~/.config/rclone/rclone.conf
echo "provider = Cloudflare" >> ~/.config/rclone/rclone.conf
echo "acl = private" >> ~/.config/rclone/rclone.conf
echo "no_check_bucket = true" >> ~/.config/rclone/rclone.conf
- name: Add mimetype for pb2
run: |
echo "application/x-protobuf pb2" | sudo tee -a /etc/mime.types
echo "80:application/x-protobuf:*.pb2" | sudo tee -a /usr/share/mime/globs2
- name: Fetch SDE
run: |
wget -q https://eve-static-data-export.s3-eu-west-1.amazonaws.com/tranquility/sde.zip
unzip sde.zip
- name: Validate SDE version
run: |
SDE_VERSION=$(date -r sde.zip "+%F" | sed 's/-//g')
RELEASE_SDE_VERSION=$(echo ${{ github.event.release.tag_name }} | cut -d- -f2)
echo "SDK version: ${SDE_VERSION}"
echo "Release version: ${RELEASE_SDE_VERSION}"
if [ "${SDE_VERSION}" != "${RELEASE_SDE_VERSION}" ]; then
echo "SDE version mismatch: ${SDE_VERSION} != ${RELEASE_SDE_VERSION}"
exit 1
fi
- name: Convert SDE YAML to Protobuf
run: |
protoc --python_out=. esf.proto
python convert.py sde/fsd
python list_shiptypes.py sde/fsd
- name: Fetch icons
run: |
python download_icons.py sde/fsd
- name: Build package
run: |
npm run build
- name: Publish package
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
registry: "https://npm.pkg.github.com"
package: package.json
- name: Publish to R2 bucket
run: |
rclone copy dist eveshipfit:eveshipfit/${{ github.event.release.tag_name }}/ --progress --exclude=*.{js,js.map,d.ts}
env:
RCLONE_CONFIG_EVESHIPFIT_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_EVESHIPFIT_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
RCLONE_CONFIG_EVESHIPFIT_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}