Publish tagged commits with GitHub Actions #18
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: Build and upload | |
on: | |
pull_request: {} | |
push: | |
branches: | |
- '*' | |
tags: | |
- '*' | |
# Must set Settings -> Actions -> General -> Workflow permissions to | |
# "Read and write permissions" | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [amd64, arm64, armhf] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # For git describe | |
- name: Install clickable | |
run: pip3 install --user --upgrade clickable-ut | |
- name: Build | |
env: | |
ARCH: ${{ matrix.arch }} | |
run: clickable build --arch $ARCH --output . | |
- name: Generate variables | |
id: filename | |
env: | |
ARCH: ${{ matrix.arch }} | |
run: | | |
GIT_VERSION="$(git describe --tags --always)" | |
echo "version=$GIT_VERSION" >> $GITHUB_OUTPUT | |
echo "zipname=annotate-$ARCH-$GIT_VERSION" >> $GITHUB_OUTPUT | |
- name: Upload package | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ steps.filename.outputs.zipname }} | |
path: annotate.semphris_*.click | |
- name: Upload to the OpenStore | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
OPENSTORE_API_KEY: ${{ secrets.OPENSTORE_API_KEY }} | |
shell: bash | |
run: | | |
clickable publish -- "$(git tag -l "$(git describe --tags --exact-match)" --format='%(contents)')" | |
# FIXME: If a commit and its tag are pushed at the same time, | |
# there will be two drafts created and the archives will be | |
# uploaded to one of them, but not necessarily the same. | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ steps.filename.outputs.version }} | |
files: annotate.semphris_*.click | |
draft: true |