11# brian's standard GitHub Actions release config for Perl 5 modules
2- # version 20220827.002
2+ # version 20230604.001
33# https://github.com/briandfoy/github_workflows
44# https://github.com/features/actions
55# This file is licensed under the Artistic License 2.0
6+ #
7+ # This action builds a Perl distribution and adds it as a release
8+ # on GitHub. This does not upload to PAUSE, but that wouldn't be
9+ # that hard, but that doesn't fit with my workflow since this part
10+ # happens after everything else has succeeded.
11+ #
12+ # This requires that you configure a repository secret named
13+ # RELEASE_ACTION_TOKEN with a GitHub Personal Access Token
14+ # that has "read and write" permissions on Repository/Contents
615name : release
716
17+ permissions :
18+ contents : write
19+
820on :
921 push :
22+ # tag a release commit with "release-....". This workflow then runs
23+ # whenever it sees that tag, and doesn't run for other commits.
1024 tags :
1125 - ' release-*'
26+ # With workflow_dispatch, you can trigger this manually. This is
27+ # especially handy when you want to re-run a job that failed because
28+ # the token had expired. Update the GitHub secret and re-run on the
29+ # same commit.
30+ workflow_dispatch :
31+
1232jobs :
1333 perl :
34+ # We need a GitHub secret, so create an Environment named "release"
35+ # * Go to Settings > Environment (repo settings, not account settings)
36+ # * Make an environment named "release"
37+ # * Add a secret named "RELEASE_ACTION_TOKEN" with a GitHub token with repo permissions
38+ # If you use a different token name, update "RELEASE_ACTION_TOKEN" in the last
39+ # step in this job.
40+ environment : release
1441 runs-on : ${{ matrix.os }}
1542 strategy :
1643 matrix :
@@ -31,39 +58,44 @@ jobs:
3158# cpanm first, which is easy. I can install IO::Socket::SSL with that,
3259# then switch back to cpan. I didn't explore this further, but what you
3360# see here hasn't caused problems for me.
34- # Need HTTP::Tiny 0.055 or later.
61+ #
62+ # Need HTTP::Tiny 0.055 or later. Probably don't need it at all since I'm
63+ # not using cpan here.
64+ #
65+ # Test::Manifest is there because it's a thing I do. If you are writing
66+ # modules and don't know what it is, you don't need it.
3567 - name : Install cpanm and multiple modules
3668 run : |
3769 curl -L https://cpanmin.us | perl - App::cpanminus
38- cpanm --notest IO::Socket::SSL App::Cpan HTTP::Tiny
39- cpan -M https://www.cpan.org -T ExtUtils::MakeMaker Test::Manifest
70+ cpanm --notest IO::Socket::SSL HTTP::Tiny ExtUtils::MakeMaker Test::Manifest
4071# Install the dependencies, again not testing them. This installs the
4172# module in the current directory, so we end up installing the module,
4273# but that's not a big deal.
4374 - name : Install dependencies
4475 run : |
45- cpan -M https://www.cpan.org -T .
76+ cpanm --notest --installdeps --with-suggests --with-recommends .
77+ # This makes the distribution and tests it, but assumes by the time we
78+ # got here, everything else was already tested.
4679 - name : Create distro
4780 run : |
4881 perl Makefile.PL
4982 make disttest
5083 make dist 2>/dev/null | grep Created | awk '{ print "ASSET_NAME=" $2 }' >> $GITHUB_ENV
5184 - name : version
52- run : echo "::set-output name=version::$(perl -le 'print $ARGV[0] =~ m/(.*?).tar.gz/' *.tar.gz)"
85+ run : |
86+ perl -le '($name) = $ARGV[0] =~ m/(.*?).tar.gz/; print qq(name=$name)' *.tar.gz >> $GITHUB_OUTPUT
5387 id : version
54- - name : release
55- uses : actions/create-release@v1
56- id : create_release
57- env :
58- GITHUB_TOKEN : ${{ github.token }}
59- with :
60- draft : false
61- prerelease : false
62- release_name : ${{ steps.version.outputs.version }}
63- tag_name : ${{ github.ref }}
64- body_path : Changes
88+ - name : Changes extract
89+ run : |
90+ perl -00 -lne 'next unless /\A\d+\.\d+(_\d+)?/; print; last' Changes > Changes-latest
91+ cat Changes-latest
92+ id : extract
6593 - name : upload
6694 uses : softprops/action-gh-release@v1
67- if : startsWith(github.ref, 'refs/tags/')
6895 with :
96+ body_path : Changes-latest
97+ draft : false
98+ prerelease : false
99+ name : ${{ steps.version.outputs.name }}
69100 files : " *.tar.gz"
101+ token : ${{ secrets.RELEASE_ACTION_TOKEN }}
0 commit comments