diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..33e25c4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,79 @@ +name: Build and Deploy + +on: + push: + branches-ignore: + - 'build-**' + pull_request: + branches-ignore: + - 'build-**' + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write # Required for creating releases and pushing tags + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3.6 + uses: actions/setup-python@v5 + with: + python-version: '3.6' + cache: 'pip' + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y maven + pip install PyGithub + + - name: Cache TeX Live + uses: actions/cache@v4 + with: + path: | + /tmp/texlive + ~/.texlive + key: texlive-${{ runner.os }} + + - name: Install TeX Live + run: source ./support/texlive_install.sh + + - name: Decrypt GPG key + if: github.event_name == 'push' + env: + encrypted_125c18bb9738_key: ${{ secrets.ENCRYPTED_125C18BB9738_KEY }} + encrypted_125c18bb9738_iv: ${{ secrets.ENCRYPTED_125C18BB9738_IV }} + run: | + openssl aes-256-cbc -K $encrypted_125c18bb9738_key -iv $encrypted_125c18bb9738_iv \ + -in bibbot.asc.enc -out bibbot.asc -d + + - name: Compile + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: source ./support/compile.sh + + - name: Create Git Tag and Deploy Info + if: success() && github.event_name == 'push' + id: tag_info + run: | + export GIT_TAG=build-${{ github.ref_name }}-$(date -u "+%Y-%m-%d")-${{ github.run_number }} + echo "tag_name=$GIT_TAG" >> $GITHUB_OUTPUT + git tag $GIT_TAG -a -m "Generated tag from GitHub Actions build ${{ github.run_number }}" + + - name: Deploy to GitHub Releases + if: success() && github.event_name == 'push' && github.repository == 'gipplab/bib' + uses: softprops/action-gh-release@v2 + with: + files: | + main.pdf + gipp.bib + docs/publist.html + docs/pubDFG.html + tag_name: ${{ steps.tag_info.outputs.tag_name }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index e9d0a1e..0a495e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bib [![Build Status](https://travis-ci.com/ag-gipp/bib.svg?branch=master)](https://travis-ci.com/ag-gipp/bib) +# bib ![Build Status](https://github.com/gipplab/bib/actions/workflows/build.yml/badge.svg) This repo contains publications from ag-gipp. Biblography @@ -13,12 +13,11 @@ compare the contents of both files and overwrite `gipp.bib` with `gipp_bibertool.bib`. ## Automatic release configuration -See the [travis manual](https://docs.travis-ci.com/user/deployment/releases/) to understand the release section of the [travis config](.travis.yml) +See the [GitHub Actions documentation](https://docs.github.com/en/actions/deployment/releasing/releasing-automatically-with-github-actions) to understand the release section of the [GitHub Actions workflow](.github/workflows/build.yml) -For the interaction with GitHub independently from travis, we create -a [personal access token](https://github.com/settings/tokens) and make -it available as environment variable -```bash -travis encrypt GITHUB_TOKEN= --add -``` +The GITHUB_TOKEN is automatically provided by GitHub Actions and does not need manual configuration. + +For GPG-signed commits, the following repository secrets need to be added: +- `ENCRYPTED_125C18BB9738_KEY` - Encryption key for the GPG key +- `ENCRYPTED_125C18BB9738_IV` - Initialization vector for the GPG key diff --git a/support/commitPub.sh b/support/commitPub.sh index e8c209a..65b220c 100755 --- a/support/commitPub.sh +++ b/support/commitPub.sh @@ -1,11 +1,17 @@ #!/usr/bin/env bash -echo "Travis: $TRAVIS, CI: $CI Travis build ID $TRAVIS_BUILD_ID" -[ -z "$TRAVIS" ] && exit 1 || echo "skip commit. Travis environment variable not set." +echo "CI: $CI, GitHub Actions: $GITHUB_ACTIONS, Run ID: $GITHUB_RUN_ID" +# Support both Travis and GitHub Actions +if [ -z "$TRAVIS" ] && [ -z "$GITHUB_ACTIONS" ]; then + echo "skip commit. CI environment variable not set." + exit 1 +fi gpg --import bibbot.asc git config --global user.email "bibbot@ckurs.de" git config --global user.name "BibBot" git config --global user.signingkey "1617C27854592471" git commit -S -m "Update publication list" docs/publist.html -git remote add http https://${GITHUB_TOKEN}@github.com/ag-gipp/bib.git -git push http HEAD:$TRAVIS_BRANCH +# Use GitHub Actions branch reference if available, otherwise use Travis +BRANCH=${GITHUB_REF_NAME:-$TRAVIS_BRANCH} +git remote add http https://${GITHUB_TOKEN}@github.com/gipplab/bib.git +git push http HEAD:$BRANCH exit 1 diff --git a/support/commitPubDfg.sh b/support/commitPubDfg.sh index 10389d6..cbf3bfe 100644 --- a/support/commitPubDfg.sh +++ b/support/commitPubDfg.sh @@ -1,11 +1,17 @@ #!/usr/bin/env bash -echo "Travis: $TRAVIS, CI: $CI Travis build ID $TRAVIS_BUILD_ID" -[ -z "$TRAVIS" ] && exit 1 || echo "skip commit. Travis environment variable not set." +echo "CI: $CI, GitHub Actions: $GITHUB_ACTIONS, Run ID: $GITHUB_RUN_ID" +# Support both Travis and GitHub Actions +if [ -z "$TRAVIS" ] && [ -z "$GITHUB_ACTIONS" ]; then + echo "skip commit. CI environment variable not set." + exit 1 +fi gpg --import bibbot.asc git config --global user.email "bibbot@ckurs.de" git config --global user.name "BibBot" git config --global user.signingkey "1617C27854592471" git commit -S -m "Update publication list" docs/pubDFG.html -git remote add http https://${GITHUB_TOKEN}@github.com/ag-gipp/bib.git -git push http HEAD:$TRAVIS_BRANCH +# Use GitHub Actions branch reference if available, otherwise use Travis +BRANCH=${GITHUB_REF_NAME:-$TRAVIS_BRANCH} +git remote add http https://${GITHUB_TOKEN}@github.com/gipplab/bib.git +git push http HEAD:$BRANCH exit 1 diff --git a/support/commitUp.sh b/support/commitUp.sh index 89d8922..ffdc85f 100755 --- a/support/commitUp.sh +++ b/support/commitUp.sh @@ -1,12 +1,18 @@ #!/usr/bin/env bash mv gipp_bibertool.bib gipp.bib -echo "Travis: $TRAVIS, CI: $CI Travis build ID $TRAVIS_BUILD_ID" -[ -z "$TRAVIS" ] && exit 1 || echo "skip commit. Travis environment variable not set." +echo "CI: $CI, GitHub Actions: $GITHUB_ACTIONS, Run ID: $GITHUB_RUN_ID" +# Support both Travis and GitHub Actions +if [ -z "$TRAVIS" ] && [ -z "$GITHUB_ACTIONS" ]; then + echo "skip commit. CI environment variable not set." + exit 1 +fi gpg --import bibbot.asc git config --global user.email "bibbot@ckurs.de" git config --global user.name "BibBot" git config --global user.signingkey "1617C27854592471" git commit -S -m "Reformat bib file" gipp.bib -git remote add http https://${GITHUB_TOKEN}@github.com/ag-gipp/bib.git -git push http HEAD:$TRAVIS_BRANCH +# Use GitHub Actions branch reference if available, otherwise use Travis +BRANCH=${GITHUB_REF_NAME:-$TRAVIS_BRANCH} +git remote add http https://${GITHUB_TOKEN}@github.com/gipplab/bib.git +git push http HEAD:$BRANCH exit 1