Publish packages #179
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: publish-packages | |
run-name: Publish packages | |
on: | |
push: | |
paths: | |
- .github/workflows/publish-packages.yml | |
- .github/packages/** | |
pull_request: | |
paths: | |
- .github/workflows/publish-packages.yml | |
- .github/packages/** | |
schedule: | |
# Monday at 5am EST | |
- cron: "0 10 * * 1" | |
concurrency: | |
group: "packages" | |
cancel-in-progress: true | |
jobs: | |
build-linux: | |
name: Publish package | |
env: | |
REGISTRY: ghcr.io | |
CONTAINERFILE: .github/packages/build-linux/Dockerfile | |
OUTPUT: ${{github.workspace}}/output | |
strategy: | |
matrix: | |
target: [ "build-linux", "gen-pages", "check-issues" ] | |
fail-fast: false | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Get image name | |
env: | |
REPO_NAME: ${{ github.repository }} | |
IMAGE_SUFFIX: ${{ matrix.target }} | |
run: | | |
result=$(echo "$REPO_NAME/$IMAGE_SUFFIX" | tr '[:upper:]' '[:lower:]') | |
echo "IMAGE=$result" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build package | |
id: build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ${{ env.CONTAINERFILE }} | |
target: ${{ matrix.target }} | |
load: true | |
tags: ${{ env.IMAGE }}:test | |
- name: Try building Melee (GENERATE_MAP=1) | |
if: startsWith(matrix.target, 'build-') | |
run: | | |
output="$OUTPUT/generate_map" | |
mkdir -p "$output" | |
docker run --rm \ | |
--user "$(id -u):$(id -g)" \ | |
--volume "$PWD:/input:ro" \ | |
--volume "$output:/output" \ | |
--env MAKE_FLAGS="GENERATE_MAP=1" \ | |
"$IMAGE:test" | |
- name: Try checking for code issues | |
if: matrix.target == 'check-issues' | |
run: | | |
docker run --rm \ | |
--user "$(id -u):$(id -g)" \ | |
--volume "$PWD:/input:ro" \ | |
"$IMAGE:test" | |
- name: Try generating pages | |
if: matrix.target == 'gen-pages' | |
run: | | |
output="$OUTPUT/gen_pages" | |
mkdir -p "$output" | |
docker run --rm \ | |
--user "$(id -u):$(id -g)" \ | |
--volume "$PWD:/input:ro" \ | |
--volume "$output:/output" \ | |
"$IMAGE:test" | |
- name: Upload GitHub Pages artifact | |
if: matrix.target == 'gen-pages' | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ${{env.OUTPUT}}/gen_pages | |
- name: Extract tags and labels | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE }} | |
tags: | | |
type=raw,priority=1000,value=latest,enable={{is_default_branch}} | |
type=schedule,pattern={{date 'YYYYMMDD'}} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=edge | |
type=sha | |
- name: Log into container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push package | |
uses: docker/build-push-action@v4 | |
if: github.event_name != 'pull_request' | |
with: | |
context: . | |
file: ${{ env.CONTAINERFILE }} | |
target: ${{ matrix.target }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |