Skip to content

Commit

Permalink
Add automatic release GitHub Action
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <tsmock@meta.com>
  • Loading branch information
tsmock committed Feb 14, 2023
1 parent 1d07079 commit f8c0796
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ant-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ on: workflow_dispatch
jobs:
call-workflow:
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v1
with:
java-version: 17

51 changes: 49 additions & 2 deletions .github/workflows/ant-release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,59 @@
name: Release

on:
release:
types: [created]
push:
tags:
- v.**
workflow_call:
inputs:
tag:
required: true
type: string

jobs:
call-workflow:
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v1
with:
josm-revision: "r18464"
java-version: 17

createrelease:
needs: call-workflow
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Set revision env variable
id: create_revision
run: |
if [[ ! -z "${{ inputs.tag }}" ]]; then
revision="${{ inputs.tag }}"
else
revision="${{ github.ref_name }}"
fi
echo "revision=$revision" >> $GITHUB_OUTPUT
- name: Get build
id: cache-plugin-build
uses: actions/cache@v3.0.0
with:
key: ${{ github.event.repository.name }}-${{ github.sha }}
path: |
josm/dist/${{ github.event.repository.name }}.jar
josm/dist/${{ github.event.repository.name }}-javadoc.jar
josm/dist/${{ github.event.repository.name }}-sources.jar
- name: Generate update site
id: create_update_site
run: |
ls -R .
jarname="${{ github.event.repository.name }}.jar"
jarurl="https://github.com/${{ github.repository }}/releases/download/${{ steps.create_revision.outputs.revision }}/${jarname}"
echo "${jarname};$jarurl" > updatesite
unzip -p "josm/dist/${jarname}" META-INF/MANIFEST.MF | sed 's/^/\t/' >> updatesite
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.create_revision.outputs.revision }}
files: |
josm/dist/${{ github.event.repository.name }}.jar
josm/dist/${{ github.event.repository.name }}-javadoc.jar
josm/dist/${{ github.event.repository.name }}-sources.jar
updatesite
31 changes: 31 additions & 0 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,34 @@ jobs:
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v1
with:
josm-revision: ${{ matrix.josm-revision }}
java-version: 17

createtag:
if: ${{ github.repository == 'JOSM/MapRoulette' && github.ref_type == 'branch' && github.ref_name == 'master' }}
needs: call-workflow
name: Create Tag
runs-on: ubuntu-latest
outputs:
revision: ${{ steps.create_revision.outputs.revision }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set revision env variable
id: create_revision
# Count the total commits for this branch
run: |
revision="v$(git rev-list --count HEAD)"
git tag $revision
git push -u origin $revision
echo "revision=$revision" >> $GITHUB_OUTPUT
releasing:
needs: createtag
name: Run release actions
uses: ./.github/workflows/ant-release.yml
with:
tag: ${{ needs.createtag.outputs.revision }}
secrets: inherit

0 comments on commit f8c0796

Please sign in to comment.